Block Password Resets for Administrators
Disables the "Lost your password?" flow for administrator accounts, which closes off reset-email based takeovers of the most powerful accounts.
Opens WPIDE on
Code
add_filter( 'allow_password_reset', function ( $allow, $user_id ) {
return user_can( $user_id, 'manage_options' ) ? false : $allow;
}, 10, 2 );
Notes
Administrators can still change their password from their profile, and another administrator or WP-CLI can reset it.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.