Categories
Uncategorized

how to notify a client when client details have been changed in whmcs

i some cases we need to notify a client when client details have been changed

i have cretaed hook that can handle this

this hook will send email to cleint just before client details change on whmcs core

create a php file in whmcs/includes/hooks and copy this on file

<?php
add_hook('ClientEdit', 1, function($vars) {

    $command = 'SendEmail';
    $postData = array(
        'messagename' => 'client notify account change',
        'id' => $vars[userid],
    );
    $adminUsername = 'admin'; // Optional for WHMCS 7.2 and later

    $results = localAPI($command, $postData, $adminUsername);
    logActivity('Hook variables: '.print_r($vars, true));
});

also you should create email template in general section with this name

“client notify account change”

Categories
Uncategorized

whmcs api does not handle add fund api what is the solution?

i can not create add fund invoice from api call and whmcs api dows not support to create add fund invoice from api.

i have created custom hook file that can change type of invoice created with api to add fund in database

create a php file in whmcs/includes/hooks and copy code below in that file

<?php
/**
 * Example Hook Function
 *
 * Please refer to the documentation @ https://docs.whmcs.com/Hooks for more information
 * The code in this hook is commented out by default. Uncomment to use.
 *
 * @package    WHMCS
 * @author     WHMCS Limited <[email protected]>
 * @copyright  Copyright (c) WHMCS Limited 2005-2018
 * @license    https://www.whmcs.com/license/ WHMCS Eula
 * @version    $Id$
 * @link       https://www.whmcs.com/
 */

use WHMCS\Database\Capsule;

if (!defined("WHMCS"))
    die("This file cannot be accessed directly");
add_hook('InvoiceCreated', 1, function($vars) {
    // Perform hook code here...
    $source = $vars['source'];
    $invoiceid = $vars['invoiceid'];   
if($source=='api'){
try {
    $updateinvoicetype = Capsule::table('tblinvoiceitems')
        ->where('description', 'Add Fund')
        ->where('invoiceid', $invoiceid)
        ->update(
            [
                'type' => 'AddFunds',
            ]
        );


} catch (\Exception $e) {

}
} 
});

this hook will update all invoice created from api and when description of invoice is “Add Fund”