SAC Pro includes a “Reset Users” option to reset all guest user names. It’s located under the General tab as a link that says “Reset the chat user-name cache”. Click it, and all stored usernames will be cleared from the database. This is useful especially if your site has a lot of people chatting, or users always changing names, and so forth. Generally, it’s not necessary to reset user names, but the option is there just in case. This tutorial takes it a step further with an easy way to automate the resetting/clearing of user names using WordPress Cron functionality.

How to do it..

Basically download a simple plugin, edit it to specify the time interval (e.g., every day), and then activate it on your WordPress site. Here is a step-by-step walk-through..

Step 1: Download the reset users plugin and edit the following line:

if (!defined('SACPRO_RESET_USERS_INTERVAL')) define('SACPRO_RESET_USERS_INTERVAL', 'one_day');

Change one_day to any of the following:

  • one_minute
  • one_hour
  • six_hours
  • twelve_hours
  • one_day
  • three_days
  • one_week
  • one_month
  • one_year

Or you can use any of the WordPress default cron intervals, or even define your own.

Step 2: After editing the time interval, save the changes and add to your WordPress site. Then activate normally like any other plugin.

Step 3: With the reset-user plugin active, deactivate SAC Pro via the WP Plugins screen. Then, reactivate SAC Pro to make it all happen.

Done! After completing the above steps, all chat user names will be cleared/reset automatically, at whatever time interval you specified in the plugin. You can verify this by using a free plugin such as WP Crontrol or similar.

Download plugin

Here is the download ZIP file for the reset users plugin. GPL license, use freely.

This simple plugin taps into the power of WP Cron. It adds some time intervals and functions to auto-reset user names for all chat forms.

Bonus: Specify time interval via filter hook

It’s also possible to override the time interval specified in step 1 (above), using the provided filter hook. Here is an example:

function ssacpro_reset_users_cron_interval($interval) {

	return 'twelve_hours'; // any supported time interval
}
add_filter('sacpro_reset_users_cron_interval', 'sacpro_reset_users_cron_interval');

Change the twelve_hours in the above example to whatever you’d like. Then add to your site using either of the methods described in this tutorial on adding custom code to WordPress. With this method, it is not necessary to make any changes to the reset-users plugin.