Khi sử dụng WHMCS mặc định sẽ không có thông báo khi bạn đăng nhập vào trang quản trị dành cho khách hàng. Hôm nay tôi sẽ hướng dẫn bạn thực hiện điều đó, nào bắt đầu thôi.
Tạo một tập tin có tên client_email_notify.php trong thư mục theo đường dẫn whmcs/includes/hooks. Mở tập tin vừa tạo và thêm vào đoạn code như sau:
<?php /* Client area login notification for WHMCS */ use Illuminate\Database\Capsule\Manager as Capsule; function digi_hook_client_login_notify($vars) { $userid = $vars['userid']; send_login_notify($userid); } function digi_send_login_notify($userid) { $ip = $_SERVER['REMOTE_ADDR'] ; $hostname = gethostbyaddr($ip); $userinfo = Capsule::table('tblclients')->select('firstname', 'lastname')->WHERE('id', $userid)->get(); $signature = Capsule::table('tblconfiguration')->where('setting', 'Signature')->value('value'); //greet them foreach ($userinfo as $userrow) { $firstname = $userrow->firstname; $lastname = $userrow->lastname; } $command = "sendemail"; $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 />$signature"; $values["id"] = $userid; $results = localAPI($command, $values, $adminuser); } add_hook('ClientLogin', 1, 'digi_hook_client_login_notify');
Lưu lại và kiểm tra kết quả nhé.