Jump to content
  • 0

How to update client record custom field in hook?



1 answer to this question

Recommended Posts

  • 0

To update a custom field for a client record on the "ClientEdit" hook, you can use the update_client_custom_field function provided by WHMCS. Here's an example of how you can use it:

use WHMCS\Database\Capsule;

// Update the custom field with field ID 1 for client with client ID 123
$success = Capsule::table('tblcustomfieldsvalues')
    ->where('fieldid', 1)
    ->where('relid', 123)
    ->update(['value' => 'new value']);

if ($success) {
    // Custom field update was successful
} else {
    // Custom field update failed

Note that you will need to replace 1 with the ID of the custom field you want to update, and 123 with the ID of the client whose custom field you want to update. You will also need to replace 'new value' with the new value you want to set for the custom field.

You can use this code in the "ClientEdit" hook function, which is called whenever a client record is edited in the WHMCS admin area or by the client using the client area.

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.

Answer this question...

×   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