Disable Remember Me in Login Form
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'] ?
sprintf(
'p class=login-rememberlabelinput 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.
Topic wp-login-form filters Wordpress
Category Web