Trying to change Wordpress login URL to an external Wordpress installation login page. I'm using the code below, but it can only redirect to a page or URL within the same site. I want it to redirect to an external Wordpress login URL. Any suggestions?
Thanks for your assistance!
// REDIRECT THE DEFAULT WORDPRESS LOGIN PAGE
// =============================================================
add_action('init','custom_login');
function custom_login(){
global $pagenow;
// URL for the HomePage. You can set this to the URL of any page you wish to redirect to.
$blogHomePage = get_bloginfo('url');
// Redirect to the Homepage, if it is login page. Make sure it is not called to logout or for lost password feature
if( 'wp-login.php' == $pagenow && $_GET['action']!="logout" && $_GET['action']!="lostpassword") {
wp_redirect('/login/');
exit();
}
}
wp_redirect('/login/');
towp_redirect('http://example.com')
;wp_redirect()
to an external site - just put in the full URL - but that won't actually let the user come back to the first site as logged in. For that you'll have to delve into the world of sharing cookies. It might be easier to use a single-sign-on plugin for both sites instead - that way once you log in you can get to either site.