Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * User login blocking without need for dedicated plugin.
- *
- */
- function wpgenie_check_attempted_login( $user, $username, $password ) {
- $blocked = array( 1, 2, 3 ); // user IDs you want to block
- if ( is_a ( $user, 'WP_User' ) ) {
- if ( !in_array( $user->ID, $blocked) ) {
- return $user;
- } else {
- $user = new WP_Error(
- 'account_locked',
- 'Your account has been locked. Please contact us for assistance.'
- );
- return $user;
- }
- }
- }
- add_filter('authenticate', 'wpgenie_check_attempted_login', 100, 3);
Advertisement
Add Comment
Please, Sign In to add comment