Jump to content

how to work with hooks


toshu

Recommended Posts

hi 

i have write a hook for clientAdd. what i am expecting is after creating/adding client it should call my hook and post all fields data to my other server to create that cllient in my database.

<?php
if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

define('BASE_URL','http://mydomain.com:4212/');

function add_client($vars)
{
    $url=BASE_URL.'createclient';
    $header[]='Authorization: custom:gventure';
    $header[]='Content-Type: application/json';
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($post_data));
    curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($vars));
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);
    $data=json_decode($result,true);

error_log(print_r($vars, true), 3, __DIR__.'/file.log'); //DID nothing :(

    return $data["records"];
}

add_hook("ClientAdd",1,"add_client");
?>

Other details:

  • filename is myhook.php
  • just place under /includes/hooks/ directory
  • is there any other setting i have to do in the code or panel? like registering my hooks i dont get it actually.

 i didnt get any hit from my side. using nodajs from my side. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated