Filter Hook since 2.8.0

login_url

Filters the login page URL

Description

login_url is how membership and white-label sites hide wp-login.php. Return a full URL, not a path fragment.

When it runs

Whenever wp_login_url() is built — login links, auth redirects, some REST responses.

Signature

apply_filters( 'login_url', string $login_url, string $redirect, bool $force_reauth );

Parameters

  • $login_url string — Login URL.
  • $redirect string — Redirect destination after login.
  • $force_reauth bool — Whether to force re-authentication.

Examples

Basic

add_filter( 'login_url', function( $url ) {
    return home_url( '/my-login/' );
} );

Send login links to a custom page instead of wp-login.php.

Real case

add_filter( 'login_url', function( $login_url, $redirect ) {
    $url = home_url( '/my-login/' );
    if ( $redirect ) {
        $url = add_query_arg( 'redirect_to', urlencode( $redirect ), $url );
    }
    return $url;
}, 10, 2 );

Preserve the redirect_to parameter when rewriting the login URL.

Common Use Cases

  • Custom login page URL
  • Hide wp-login.php from bots
  • Membership site login flow
  • White-label WordPress projects

Common mistakes

  • Filtering the URL without actually creating the custom login route — users hit 404

Related hooks

FAQ

Do I still need wp-login.php to exist after filtering login_url?

Only if something still links to it directly. This filter changes what wp_login_url() outputs; it doesn't disable the real wp-login.php endpoint.

Source: wp-includes/general-template.php

Group wizard

One session: this hook, then each related_hooks entry. Walk it and tell us what to change.

login_url → admin_init

functions.php — login_url
functions.php
PHP login_url · Hook 1 of 2 · Step 1 of 7

Practice the login_url WordPress filter hook in our interactive sandbox — a VS Code-style editor with a step-by-step login_url tutorial, add_filter exercises, and instant feedback. No local WordPress install required.