apply_filters( 'login_url', string $login_url , string $redirect , bool $force_reauth )
Filters the login URL.
Parameters
-
$login_url
string -
The login URL. Not HTML-encoded.
-
$redirect
string -
The path to redirect to on login, if supplied.
-
$force_reauth
bool -
Whether to force reauthorization, even if a cookie is present.
More Information
login_ur
l is a filter applied to the url returned by the function wp_login_url()
Source
File: wp-includes/general-template.php
.
View all references
return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
Changelog
Version | Description |
---|---|
4.2.0 | The $force_reauth parameter was added. |
2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Here’s an example of filtering the `login_url` to specify a custom one:
Tested this login_url filter and it works fine for login links on the website, for example on blog pages.
The filter will not work for a browser URL like /wp-login.php.
This can be useful in case you have a custom login form for subscribers, while administrators still login with the WordPress core login form when two-factor authentication is enabled.
A custom login form like those of User Registration plugin will not work with 2FA. This is where the core login form is still useful.
Examples migrated from Codex:
The following example would return a login URL http://example.com/my-login-page/ for the
wp_login_url()
function:Same as above, but uses the
add_query_arg()
function for adding the redirect_to parameter and is expanded for readability.