Resetting user logs - Can I reset the logs to 0 and filter out my IP

Can I reset the User Activity logs to 0 and also filter myself out?

Thanks,

Sandra

  • Adam Czajczyk

    Hello Sandra,

    I hope you're well today and thank you for your question!

    You can reset User Activity logs in a WP database directly. In order to do this

    - disable the plugin in your dashboard
    - access your site's database with phpMyAdmin
    - select "wp_user_activity" table
    - remove all data
    - select "wp_user_activity_log" table
    - remove all data

    This should clear all logs.

    As for excluding an account from activity logs.

    This is doable but you will want to edit plugin's code in order to achieve it. Therefore it would be best to note down the changes in order to be able to re-apply them in case of plugin's update. To exclude any given account(s) from User Activity logs please follow these steps:

    - access your site via FTP
    - go to /wp-content/plugins/user-activity/ folder
    - edit the "user-activity.php" file with clean-text editor (e.g. Notepad++, Sublime, any PHP editor/IDE)
    - find this code:

    /**
    	 * Create or update current user activity entry
    	 **/
    	function global_db_sync() {
    		global $wpdb, $current_user;
    
    		if ( '' !== $current_user->ID ) {

    and replace it with this:

    /**
    	 * Create or update current user activity entry
    	 **/
    	function global_db_sync() {
    		global $wpdb, $current_user;
    
    		$excluded_users = array(1);
    		if (in_array($current_user->ID,$excluded_users)) return;
    
    		if ( '' !== $current_user->ID ) {

    Please take as look at this line:

    $excluded_users = array(1);

    It's where you add user ID(s) of user(s) that are to be excluded from logs. Currently this is set to user of ID "1" which is a default ID for admin. You may want however to replace it with an ID of any other user. You may also want to add more users there by listing more IDs separated by commas, for example:

    $excluded_users = array(1,4,20);

    You'll find an ID of the user by going to your dashboard's "Users -> All Users" page and placing cursor pointer over selected user name. You should then see an URL in your browser's status bar including "user_id=X" part where "X" is an ID of the user.

    Please make sure that you took full backup of your database and backup of "user-activity.php" file prior to performing described actions.

    I hope that helps!
    Best regards,
    Adam