I need to disable the 'Remember Me' prompt in login screens.

Based on answers here https://wordpress.stackexchange.com/a/306746/29416 (including my own answer from 2018 with code that I had working then) about disabling the "Remember Me" prompt on the WP login form (wp-login.php), I should be able to do this:

    add_filter('login_form_defaults', 'my_disable_remember_me');
    function my_disable_remember_me($args) {
        $args['remember']       = "";
        return $args;

This is based on looking at wp-login.php (around line 604) where the 'remember' arguments shows the 'Remember Me' prompt. If the value is empty, or false, the HTML starting in line 605 will not be displayed. This is the code in wp-login.php that outputs the "Remember Me' text and checkbox (line 604).

  ( $args['remember'] ?
            '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="%1$s" value="forever"%2$s /> %3$s</label></p>',
            esc_attr( $args['id_remember'] ),
            ( $args['value_remember'] ? ' checked="checked"' : '' ),
            esc_html( $args['label_remember'] )
        ) : ''
    ) .

So using that filter 'login_form_defaults' should remove the prompt. But it doesn't. I have tried the other filters (login_form_top, login_form_middle, login_form_footer) to use the same my_disable_remember_me function, to no avail.

So I am confused as to why the login_form_defaults doesn't remove the "Remember Me" checkbox and text.

1 Answer 1


The login_form_defaults hook does work, but wp-login.php does not use wp_login_form() which runs the login_form_defaults hook, and instead the "Remember Me" checkbox is echoed like this, hence it's basically unremovable via PHP or there's no filter to disable (or an argument to bypass) the echo, or empty/modify the markup.

So that means, if wp_login_form() was used, then your code would have worked.

But on the wp-login.php page, you can disable the "Remember Me" via either CSS or JS, or both:

  • Use CSS to visually hide the checkbox, e.g. using the login_head hook:

    add_action( 'login_head', function () {
        echo '<style>.forgetmenot { display: none !important }</style>';
    } );
  • Use JS to completely remove the element, e.g. using the login_footer hook:

    add_action( 'login_footer', function () {
                try {
                    document.querySelector( '.forgetmenot' ).remove();
                } catch ( err ) {}
    } );

Or just create a custom login page and send users to that page instead when they attempt to login.

That way, you can manually call wp_login_form() and just disable the "Remember Me" as you wish.

  • But I see the 'login_form_defaults' filter in general-templates.php about line 540 , which is what login_form() uses. I can't get the filter to accept non-default 'remember' element in the $args used in general-templates.php . Mar 30, 2022 at 2:07
  • Are you actually trying to disable the "Remember Me" on the wp-login.php page or somewhere else? If it is the former, then as stated in my answer, wp-login.php does not use wp_login_form() which runs the login_form_defaults hook, so it's normal if your my_disable_remember_me() function didn't work (because it never runs on that page).
    – Sally CJ
    Mar 30, 2022 at 2:34
  • I have revised my answer, but please let me know if I have perhaps misunderstood your actual question?
    – Sally CJ
    Mar 30, 2022 at 2:49
  • As for this: "I can't get the filter to accept non-default 'remember' element in the $args", if you look at line 503, it says, @type bool $remember Whether to display the "rememberme" checkbox in the form, so remember is just a (boolean) flag and therefore, if you were actually trying to use your own checkbox, then you can use the login_form_middle filter to add your markup and set the remember to false. But once again, wp-login.php does not use wp_login_form() (but yes, the inputs by default are sent to wp-login.php).
    – Sally CJ
    Mar 30, 2022 at 3:35
  • 1
    Thanks for the clear explanation. I assumed, without digging deeply, that the wp-login.php was using wp_login_form, which I was changing via the filter. (Why that is - is puzzling.) Your JS code worked perfectly. Thanks. Mar 30, 2022 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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