Here is how to clear your WHMCS client last login IP’s and host entries automatically for privacy.
Probably not a popular modification, but running a security and privacy company we wanted to automate and prevent any unnecessary logging being done when clients login to the billing/support center.
These are stored in the table “tblclients” and in columns “ip” and “host”.
whmcs_database »Table: tblclients > ip,host
Replace the below values with your cPanel username and
In my case, I created a new database user with only “update” privileges on the WHMCS
To create the bash script:
This can be done via SSH via nano
nano whmcs-client-clear-ip.sh
Or via the cPanel FileManager create a new file named “whmcs-client-clear-ip.sh”
With the below lines:
#!/usr/bin/env bash
## Author: Michael Ramsey
## Objective clear client login ips in whmcs logs
## Start Config ##
DB_NAME='database_name';
DB_USERNAME='database_username';
export PASSWORD='Passwordhere';
## END Config ##
# Clear clients last login IP address in table tblclients > ip,host
mysql "${DB_NAME}" -u "${DB_USERNAME}" "-p${PASSWORD}" -e "UPDATE tblclients SET ip = '', host = ''"
# WHMCS Clear last login IP address in tblusers last_ip last_hostname
mysql "${DB_NAME}" -u "${DB_USERNAME}" "-p${PASSWORD}" -e "UPDATE tblusers SET last_ip = '', last_hostname = ''"
# Clear Order Ipaddress in table tblorders > ipaddress
mysql "${DB_NAME}" -u "${DB_USERNAME}" "-p${PASSWORD}" -e "UPDATE tblorders SET ipaddress = ''"
# Clear Order Ipaddress in table tblactivitylog > ipaddr where Client
mysql "${DB_NAME}" -u "${DB_USERNAME}" "-p${PASSWORD}" -e "UPDATE tblactivitylog SET ipaddr = '' WHERE user = 'Client'"
unset PASSWORD
Then in the cPanel cronjobs or via ssh “crontab -e” add the below cronjob to clear this every minute.
* * * * * /bin/sh /home/username/whmcs-client-clear-ip.sh >/dev/null 2>&1
To test if it’s working I recommend setting it to every 5 minutes like the below.
*/5 * * * * /bin/sh /home/username/whmcs-client-clear-ip.sh >/dev/null 2>&1
Then log in to a test account to generate a last login
Go change the
If it’s not working then run the command from the second line of the script in the command line via ssh first to see if there is an error or typo. If it is fix it then update the bash script and you should be all set.
Hope this helps someone else and also probably helpful for huge company’s to save space in their database from clients activity.