How to disable register and reset the password from WordPress admin panel?

Please I want to do this by codes without using plugins.


put the code bellow into functions.php :

class Password_Reset_Removed

  function __construct() 
    add_filter( 'show_password_fields', array( $this, 'disable' ) );
    add_filter( 'allow_password_reset', array( $this, 'disable' ) );
    add_filter( 'gettext',              array( $this, 'remove' ) );

  function disable() 
    if ( is_admin() ) {
      $userdata = wp_get_current_user();
      $user = new WP_User($userdata->ID);
      if ( !empty( $user->roles ) && is_array( $user->roles ) && $user->roles[0] == 'administrator' )
        return true;
    return false;

  function remove($text) 
    return str_replace( array('Lost your password?', 'Lost your password'), '', trim($text, '?') ); 

$pass_reset_removed = new Password_Reset_Removed();

add the following to your themes functions.php file to disable register:

   add_action( 'login_head', 'hide_login_nav' );

function hide_login_nav()
  • This will hide the links only or disabled register and reset from admin panel? and for first codes you mean add it into functions.php of WordPress files? – Yogu May 13 '17 at 20:01
  • Put it into your theme functions file. – Porosh Ahammed May 13 '17 at 20:04
  • Sorry but it hides the text only the URL is still working. – Yogu May 13 '17 at 20:15

First part, remove registration, does not require any code. Simply uncheck the box 'Anyone can register' in 'Settings -> General -> Membership'.

Second part, remove password reset functionality, consists of two parts, removing ( hiding ) 'Lost your password?' link from login form, and removing ( hiding ) 'Account Management' section from user's profile page. Unfortunately, removing them, violates both, website's ( admin ) and user's security. Therefore, although technically possible, I'm not going to provide a solution for the second part.

Third part - code asked for, definitely belongs to a plugin, as it should be themes independent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.