dottedquad Posted June 17, 2017 Share Posted June 17, 2017 I have a working ClientAdd hook and would like to extend its feature to access the custom text field named "website". Does anyone have an example of how to grab the custom fields value? Also, I noticed the Docs mentions "customFields" variable for ClientAdd, but I don't see that variable in ClientEdit docs. Is it possible to access customFields from the ClientEdit hook? 1 Quote Link to comment Share on other sites More sharing options...
dottedquad Posted June 17, 2017 Author Share Posted June 17, 2017 I dug a little further and figured out how to access the customFields via $vars['customfields']['1']; , but it seems that I cannot access the customeFields inside of the clientEdit hook. I placed a die(json_encode($vars)); at the top in the clientEdit hook to output the array in JSON format so its easily readable. I then noticed the customfield could be accessible from within "olddata", but that defeats the purpose of getting the 'updated' field value. Will I need to use the Capsule API access the value via mysql? 1 Quote Link to comment Share on other sites More sharing options...
dottedquad Posted June 17, 2017 Author Share Posted June 17, 2017 Using this example, I can access the customfield 'website' field value code: <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); use WHMCS\Database\Capsule; add_hook('ClientEdit', 1, function($vars) { //die(json_encode($vars)); $userid = $vars['userid']; foreach (Capsule::table('tblcustomfieldsvalues')->where('fieldid','1')->where('relid', $userid)->get() as $client) { //Do stuffs } }); So, my question still remains.... Do I need to use the Capsule API to access the customfields value from the clientEdit hook? Or am I overlooking something? 1 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.