7seas Posted March 2, 2016 Share Posted March 2, 2016 Hi, Well I tryed to use the autoauth for login customers. I use this code : <?php Define WHMCS URL & AutoAuth Key $whmcsurl = "https://www.domain.com/clients/dologin.php"; $autoauthkey = "abcXYZ123"; $timestamp = time(); # Get current timestamp $email = "demo@123.com"; # Clients Email Address to Login $goto = "clientarea.php?action=products"; $hash = sha1($email.$timestamp.$autoauthkey); # Generate Hash Generate AutoAuth URL & Redirect $url = $whmcsurl."?email=$email×tamp=$timestamp&hash=$hash&goto=".urlencode($goto); header("Location: $url"); exit; ?> I use WordPress to do this and the code is in a file at the root of Wordpress. I call the file with a link . It could work perfect! but what should I write to replace the email address "demo@123.com" I think it's story of variable but I don't know anymore . Can you please advise me? Thank 0 Quote Link to comment Share on other sites More sharing options...
7seas Posted March 3, 2016 Author Share Posted March 3, 2016 Normally to retrieve the email address of the Wordpress administrator ther's that : $admin_email = get_option( 'admin_email' ) (or maybe I am wrong) How can I handle it for the Autoauth code? 0 Quote Link to comment Share on other sites More sharing options...
7seas Posted March 3, 2016 Author Share Posted March 3, 2016 I found this code to insert in functions.php file of Worpress: function callwhmcsapi($action,$params){ $whmcsapiurl = "http://yourwhmcsurl.com/includes/api.php"; $whmcsusername = "adminuser"; // User with API privileges $whmcspassword = "adminpassword"; $params['username'] = $whmcsusername; $params['password'] = md5($whmcspassword); $params['action'] = $action; $params['responsetype'] = "json"; $query_string = ""; foreach ($params AS $k=>$v) $query_string .= "$k=".urlencode($v)."&"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $whmcsapiurl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $jsondata = curl_exec($ch); if (curl_error($ch)) die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); curl_close($ch); $result = json_decode($jsondata,true); return $result; } function addwhmcsclient($name,$email){ $params["firstname"] = $name[0]; $params["lastname"] = $name[1]; $params["email"] = $email; $params["address1"] = "1301 College Avenue"; // We use the school's address for all users in the system $params["city"] = "Fredericksburg"; $params["state"] = "Virginia"; $params["postcode"] = "22401"; $params["country"] = "US"; $params["phonenumber"] = "5406541000"; $params["password2"] = ""; $result = callwhmcsapi("addclient",$params); return $result; } And my code to call : function wp_get_current_user() { global $current_user; return $current_user; } function checkwhmcsclient() { global $clientsuccess; return $clientsuccess; } $current_user = wp_get_current_user(); $email = $current_user->user_email; $name = array(); $name[0] = $current_user->user_firstname; $name[1] = $current_user->user_lastname; $clientsuccess = checkwhmcsclient($email); $whmcsurl = "https://mydomain/whmcs/dologin.php"; $autoauthkey = "abcXYZ123"; $timestamp = time(); # Get current timestamp $email = $clientsuccess['email']; # Clients Email Address to Login $goto = "clientarea.php?action=products"; $hash = sha1($email.$timestamp.$autoauthkey); # Generate Hash # Generate AutoAuth URL & Redirect $url = $whmcsurl."?email=$email×tamp=$timestamp&hash=$hash&goto=".urlencode($goto); ?> <script> window.location.href="<?php echo $url; ?>";</script> <?php get_footer(); ?> But it doesn't make the job. I think I am on the good wat. Can anyone helps me ? Pleeease 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.