Created
February 27, 2016 16:35
-
-
Save carlodaniele/b6c6e155c5fe97222546 to your computer and use it in GitHub Desktop.
Switch the URL of default login page with the URL of a custom login page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set a custom login page | |
* | |
* @param string $url Default login URL | |
* @param string $redirect Redirect URL on login | |
* @param bool $force_reauth Whether to force reauthorization | |
* @link https://developer.wordpress.org/reference/hooks/login_url/ | |
*/ | |
function frontend_login_url( $url, $redirect, $force_reauth ){ | |
$new_login_url = home_url( '/login-form/' ); | |
if ( !empty($redirect) ){ | |
$new_login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $new_login_url ); | |
} | |
if ( $force_reauth ){ | |
$new_login_url = add_query_arg( 'reauth', '1', $new_login_url ) ; | |
} | |
return $new_login_url; | |
} | |
add_filter( 'login_url', 'frontend_login_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment