earthgirlllc Posted January 26, 2019 Share Posted January 26, 2019 Hi, can't find this in the documentation. I need to implement a hook on three specific hosting package numbers. How would I go about doing that? TIA 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 27, 2019 Share Posted January 27, 2019 16 hours ago, earthgirlllc said: I need to implement a hook on three specific hosting package numbers. How would I go about doing that? it depends on the hook! 🙂 you're going to have to get the current product IDs - usual place would be from the template using $vars, and then you just use if statements (or in_array if all three result in the hook doing the same thing) to check the value of pid... but as I said, that pid value might be in a different array depending on the template you're working with... it might not even exist and you'll have to get it by using another variable. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted January 31, 2019 Share Posted January 31, 2019 Which hook are you trying to use? Or in other words, what is the goal of your hook? Each hook has their own vars given to them. 0 Quote Link to comment Share on other sites More sharing options...
earthgirlllc Posted January 31, 2019 Author Share Posted January 31, 2019 I still need to create the hook - it would be specific to hosting package #s and would call the API to create an email address for that account. 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted January 31, 2019 Share Posted January 31, 2019 Okay, but what specific hook? There dozens of them as shown in https://developers.whmcs.com/hooks/hook-index/ Hooks are triggered at different times for different actions. So you need to pick the hook and come back here and let me know which action you trying to hook in to. From the sound of it, however, you may want to look at server provisioning modules as that would be package specific and provide the functions needed to do the create, suspend, and terminate for that email account. If you are already using a module for that and need additional actions, then either the module needs to take care of it or you can use the after or pre module hooks listed in the link above. Those hooks will provide the package that is being worked on and you can then do the needed actions. 0 Quote Link to comment Share on other sites More sharing options...
earthgirlllc Posted January 31, 2019 Author Share Posted January 31, 2019 Duh - sorry, AfterModuleCreate 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted January 31, 2019 Share Posted January 31, 2019 <?php add_hook('AfterModuleCreate', 1, function($vars) { $packageid = $vars['pid']; $Package = WHMCS\Product::find($packageid); if ($Package and $Package->id === 5) { $APi = new externalAPI(); $API->createAddress("webmaster@".$vars['domain']); } if ($Package and $Package->id === 1) { $APi = new blah(); $API->blahAction(); } }); 1 Quote Link to comment Share on other sites More sharing options...
earthgirlllc Posted January 31, 2019 Author Share Posted January 31, 2019 Thank you, thank you!! 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.