Jump to content

ClientAdd and ClientEdit hook access to custom field?

Recommended Posts

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?

Share this post

Link to post
Share on other sites

I dug a little further and figured out how to access the customFields via


, but it seems that I cannot access the customeFields inside of the clientEdit hook. I placed a


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?

Share this post

Link to post
Share on other sites

Using this example, I can access the customfield 'website' field value




if (!defined("WHMCS"))

die("This file cannot be accessed directly");


use WHMCS\Database\Capsule;


add_hook('ClientEdit', 1, function($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?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.


Important Information

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