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
Or via the cPanel FileManager create a new file named “whmcs-client-clear-ip.sh”
With the below lines:
#!/bin/sh #Clear clients last login IP address in table tblclients > ip,host /usr/bin/mysql -h "localhost" -u "database_username" "-pPasswordhere" -e "UPDATE tblclients SET ip = '', host = ''" database_name #Clear Order Ipaddress in table tblorders > ipaddress /usr/bin/mysql -h "localhost" -u "database_username" "-pPasswordhere" -e "UPDATE tblorders SET ipaddress = ''" database_name
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.