Notice: Function _load_textdomain_just_in_time được gọi không chính xác. Tải bản dịch cho miền swyft được kích hoạt quá sớm. Đây thường là dấu hiệu cho thấy một số mã trong plugin hoặc chủ đề chạy quá sớm. Bản dịch phải được tải tại hành động init hoặc sau đó. Vui lòng xem Hướng dẫn Debug trong WordPress để biết thêm thông tin. (Thông điệp này đã được thêm vào trong phiên bản 6.7.0.) in /home/digipower/domains/digipower.io.vn/public_html/wp-includes/functions.php on line 6121
Thông báo tài khoản đăng nhập WHMCS - Code hay, Thủ thuật WordPress, Hosting, VPS...

Thông báo tài khoản đăng nhập WHMCS

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é.