Using WordPress ‘login_form_defaults’ PHP filter

login_form_defaults is a WordPress PHP filter that allows you to modify the default arguments of the login form output.

Usage

add_filter('login_form_defaults', 'your_custom_function');
function your_custom_function($defaults) {
    // your custom code here
    return $defaults;
}

Parameters

  • $defaults (array): An array of default login form arguments.

More information

See WordPress Developer Resources: login_form_defaults

Examples

Change the login form title

Customize the login form title by updating the ‘title’ value in the $defaults array.

add_filter('login_form_defaults', 'change_login_form_title');
function change_login_form_title($defaults) {
    $defaults['title'] = 'Custom Login';
    return $defaults;
}

Change the login button text

Modify the text displayed on the login button by updating the ‘label_log_in’ value in the $defaults array.

add_filter('login_form_defaults', 'change_login_button_text');
function change_login_button_text($defaults) {
    $defaults['label_log_in'] = 'Sign In Now';
    return $defaults;
}

Set a custom redirect URL after login

Set a custom URL to redirect users to after a successful login by updating the ‘redirect’ value in the $defaults array.

add_filter('login_form_defaults', 'set_custom_redirect_url');
function set_custom_redirect_url($defaults) {
    $defaults['redirect'] = 'https://example.com/custom-dashboard';
    return $defaults;
}

Hide the “Remember Me” checkbox

Hide the “Remember Me” checkbox by setting the ‘remember’ value in the $defaults array to false.

add_filter('login_form_defaults', 'hide_remember_me_checkbox');
function hide_remember_me_checkbox($defaults) {
    $defaults['remember'] = false;
    return $defaults;
}

Set a custom ID for the login form

Assign a custom ID to the login form by updating the ‘id_form’ value in the $defaults array.

add_filter('login_form_defaults', 'set_custom_login_form_id');
function set_custom_login_form_id($defaults) {
    $defaults['id_form'] = 'custom-login-form';
    return $defaults;
}