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.
Source
return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
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.