Rusky Posted September 6, 2019 Share Posted September 6, 2019 Hi, hope someone can help me with this one... I'm trying to create a ClientAdd webhook that triggers a Catch Hook in Zapier. So far I've... 1. Created a file called ClientAdd.php in includes/hooks (see code below) 2. Setup the Catch Hook in Zapier. I'm not a developer, so not sure if my code below is correct. I feel something might be missing to make this work properly or the webhook isn't triggering in WHMCS. Anyone able to assist? <?php /** * Register hook function call. * * @param string $hookPoint The hook point to call * @param integer $priority The priority for the given hook function * @param string|function Function name to call or anonymous function. * * @return Depends on hook function point. */ add_hook('ClientAdd', 1, function ($vars) { $userid = $vars['userid']; $firstname = $vars['firstname']; $lastname = $vars['lastname']; $companyname = $vars['companyname']; $email = $vars['email']; $address1 = $vars['address1']; $address2 = $vars['address2']; $city = $vars['city']; $state = $vars['state']; $postcode = $vars['postcode']; $country = $vars['country']; $phonenumber = $vars['phonenumber']; $tax_id = $vars['tax_id']; $emailoptout = $vars['emailoptout']; $notes = $vars['notes']; // Run code here... https://hooks.zapier.com/hooks/catch/XXXXXXX/XXXXX/silent/ (URL changed for security) }); I'm also unable to see anywhere in the logs where I can confirm that the WHMCS webhook has run after the ClientAdd event is triggered? As far as I can tell nothing is being triggered on the Zapier end by my code above. Cheers John 0 Quote Link to comment Share on other sites More sharing options...
chackiath Posted November 5, 2020 Share Posted November 5, 2020 Did you get this sorted ? 0 Quote Link to comment Share on other sites More sharing options...
igurman Posted December 11, 2020 Share Posted December 11, 2020 Hey guys, so in case somebody else is looking for this.. (I am quite amazed that this is not a built in feature in WHMCS yet.. but oh well): Rusky you can't just paste the webhook URL and expect it to receive parameters, it's PHP code and you need to utilizie it. Here is an example of a hook file, that will send the first & last name of new customers, to your zapier hook: add_hook('ClientAdd', 1, function ($vars) { $userid = $vars['userid']; $firstname = $vars['firstname']; $lastname = $vars['lastname']; // Posting of the info -> Zapier Webhook echo file_get_contents('https://hooks.zapier.com/hooks/catch/WEBHOOK/', false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded", 'content' => http_build_query([ 'firstname' => $firstname, 'lastname' => $lastname ]) ] ])); }); So you can adjust it to send whatever parameters you'd like bout your new order. Here you can find the full reference of available parameters. Ilya 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.