Reset the Counters – with solution
-
1. Install WPCode snippets library
2. Paste in the following code block into a PHP code type
3. Change the user ID below (currently 100) to the user ID that you want the login count to reset for (positive int only!)
4. Change the login count (200) to whatever you want below
5. Save snippet
6. Turn snippet on
7. Save again (this is what actually runs the snippet)
7. Check user login count in WP admin
8. Turn snippet off
9. Save snippet
10. If you need to run this again in future, change any instances of “01” below to an incrementing number
11. If you need to run this for multiple IDs, leave a commentfunction scratchcode_run_code_one_time() { if ( !get_option('run_only_once_01') ): // Execute your one time code here $user_id= 100; $login_count = intval(200); update_user_meta( $user_id, 'wp_login_count', ( (int) $login_count ) ); add_option('run_only_once_01', 1); endif; } add_action( 'init', 'scratchcode_run_code_one_time' );
`
- The topic ‘Reset the Counters – with solution’ is closed to new replies.