hmaddy Posted May 1 Share Posted May 1 i would like to create a hook to validate the customer email id when customer register the profile on whmcs. i created the following code. i need to validate the email and save the result to a txt file. but its not working. so can you please help me. Api mentioned on this code is dummy. <?php use WHMCS\View\Menu\Item as MenuItem; use WHMCS\Database\Capsule; add_hook('ClientAdd', 1, function($vars) { // Perform hook code here... $firstname = $vars->firstname; $sourceemail = $vars->email; $sourceuserid = $vars->client_id; // Prepare API URL $api_key = "myapi"; $email = urlencode($sourceemail); $ip_address = "13.16.6.253"; // Assuming this is a static IP address $api_url = "https://api.zerobounce.net/v2/validate?api_key=$api_key&email=$email&ip_address=$ip_address"; // Initialize cURL session $ch = curl_init(); // Set cURL options curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute cURL session $response_json = curl_exec($ch); // Close cURL session curl_close($ch); // Decode JSON response $response = json_decode($response_json); // Extract status from response $status = $response->status; // Save $status to a text file $filename = $sourceemail . '.txt'; $file_content = "Status: $status\n"; file_put_contents($filename, $file_content); // Optional: Display the status echo "Status for $sourceemail: $status"; // Optional: Display any errors if ($status !== 'valid') { echo "Validation failed for $sourceemail"; } error_reporting(E_ALL); ini_set('display_errors', 1); }); 0 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.