I have stored the API information for API I wish to tie WHMCS into in the "Module Addon" configuration screen for that module. The documentation makes it seem like I should be able to access it from the $vars array. But when I dump that array, I don't see my configuration in there. How do I get my API credentials?
Addon module settings are stored in tbladdonmodules
table. So for addon module example_addon, to get settings use the following code:
use WHMCS\Database\Capsule as DB;
add_hook('ClientAreaPage', 1, function($vars) {
$targetValue = ''; // Default value if no setting found
$setting = DB::table('tbladdonmodules')->select('value')->where('module', 'example_addon')->where('setting', 'target_config')->first();
if (!empty($setting)) {
$targetValue = $setting->value;
}
// TODO: use $targetValue
});