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_urlstring — Login URL.$redirectstring — Redirect destination after login.$force_reauthbool — 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