hebergeni Posted July 18, 2016 Share Posted July 18, 2016 Hello How can i please send a mail notification when client is log in to his clientarea any help please 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted July 19, 2016 Share Posted July 19, 2016 (edited) Here you go. Save this as a php file in whmcs/includes/hooks. Change the 'adminuser' to be your username (or another full admin) <?php /* Client area login notification for WHMCS Developed by http://www.whmcsguru.com */ use Illuminate\Database\Capsule\Manager as Capsule; function hook_client_login_notify($vars) { $userid = $vars['userid']; send_login_notify($userid); } function send_login_notify($userid) { $ip = $_SERVER['REMOTE_ADDR'] ; $hostname = gethostbyaddr($ip); $userinfo = Capsule::table('tblclients')->select('firstname', 'lastname')->WHERE('id', $userid)->get(); //greet them foreach ($userinfo as $userrow) { $firstname = $userrow->firstname; $lastname = $userrow->lastname; } $command = "sendemail"; $adminuser = "YOUR ADMIN USERNAME HERE"; $values["customtype"] = "general"; $values["customsubject"] = "Account Login from $hostname"; $values["custommessage"] = "<p>Hello $firstname $lastname,<p>Your account was recently successfully accessed by a remote user. If this was not you, please do contact us immediately<p>IP Address: $ip<br/>Hostname: $hostname<br />"; $values["id"] = $userid; $results = localAPI($command, $values, $adminuser); } add_hook('ClientLogin', 1, 'hook_client_login_notify'); This uses Hooks:ClientLogin and API:SendEmail Nothing else needed, this will detect the ip (and hostname) and let the user know via mail. Edited July 19, 2016 by twhiting9275 sanitized. Looks like the php flag is broken 0 Quote Link to comment Share on other sites More sharing options...
wsa Posted July 19, 2016 Share Posted July 19, 2016 (edited) it was a error Edited July 19, 2016 by wsa It was a mistake 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 19, 2016 Share Posted July 19, 2016 it on my site oh dear - self promoting outside of Third-Party Addons and Marketplace... tut tut. 0 Quote Link to comment Share on other sites More sharing options...
hebergeni Posted December 2, 2016 Author Share Posted December 2, 2016 Hello Thank you it works for me but how we can prevent to send mail when i acces to clients account from adminpanel please thank you 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted December 5, 2016 Share Posted December 5, 2016 Here you go <?php /* Client area login notification for WHMCS Developed by http://www.whmcsguru.com v1.0.1 */ use Illuminate\Database\Capsule\Manager as Capsule; function hook_client_login_notify($vars) { $userid = $vars['userid']; $adminid = $_SESSION['adminid']; if (empty($adminid)) { send_login_notify($userid); } } function send_login_notify($userid) { $ip = $_SERVER['REMOTE_ADDR'] ; $hostname = gethostbyaddr($ip); $userinfo = Capsule::table('tblclients')->select('firstname', 'lastname')->WHERE('id', $userid)->get(); //greet them foreach ($userinfo as $userrow) { $firstname = $userrow->firstname; $lastname = $userrow->lastname; } $command = "sendemail"; $adminuser = "twhiting9275"; $values["customtype"] = "general"; $values["customsubject"] = "Account Login from $hostname"; $values["custommessage"] = "<p>Hello $firstname $lastname,<p>Your account was recently successfully accessed by a remote user. If this was not you, please do contact us immediately<p>IP Address: $ip<br/>Hostname: $hostname<br />"; $values["id"] = $userid; $results = localAPI($command, $values, $adminuser); } add_hook('ClientLogin', 1, 'hook_client_login_notify'); This will check for an admin session variable, and if exists, won't mail the client upon login 0 Quote Link to comment Share on other sites More sharing options...
hebergeni Posted January 7, 2017 Author Share Posted January 7, 2017 Thank you very much 0 Quote Link to comment Share on other sites More sharing options...
hebergeni Posted January 16, 2017 Author Share Posted January 16, 2017 How can i please fetch date and time of login thank you again 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted January 16, 2017 Share Posted January 16, 2017 That's kind of redundant, as they will be receiving this as they are logged in 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.