Using WordPress ‘login_headerurl’ PHP filter

The login_headerurl filter allows you to change the URL of the logo on the WordPress login page.

Usage

add_filter('login_headerurl', 'your_custom_function');

function your_custom_function($login_header_url) {
    // Your custom code here
    return $login_header_url;
}

Parameters

  • $login_header_url (string): The current URL of the login header logo.

More information

See WordPress Developer Resources: login_headerurl

Examples

Change the logo URL to the homepage

This example changes the logo URL to point to the homepage.

add_filter('login_headerurl', 'change_logo_url_to_homepage');

function change_logo_url_to_homepage($login_header_url) {
    return home_url();
}

Change the logo URL to a custom URL

This example changes the logo URL to a custom URL (e.g., your company website).

add_filter('login_headerurl', 'change_logo_url_to_custom');

function change_logo_url_to_custom($login_header_url) {
    return 'https://www.example.com';
}

Change the logo URL based on user role

This example changes the logo URL based on the user’s role.

add_filter('login_headerurl', 'change_logo_url_based_on_role');

function change_logo_url_based_on_role($login_header_url) {
    $user = wp_get_current_user();
    if (in_array('administrator', $user->roles)) {
        return 'https://www.example.com/admin-dashboard';
    }
    return 'https://www.example.com/user-dashboard';
}

Change the logo URL for a specific theme

This example changes the logo URL only if a specific theme is active.

add_filter('login_headerurl', 'change_logo_url_for_theme');

function change_logo_url_for_theme($login_header_url) {
    $theme = wp_get_theme();
    if ($theme->get('Name') === 'My Custom Theme') {
        return 'https://www.example.com/custom-theme-url';
    }
    return $login_header_url;
}

Remove the logo URL

This example removes the URL from the logo, making it unclickable.

add_filter('login_headerurl', 'remove_logo_url');
function remove_logo_url($login_header_url) {
    return '';
}