In this article, we discuss about how to redirect custom login page WordPress without any plugins. Before we get started, if you want to know about different menu of Guest and User of WordPress, please go through the following article: How to change menu after login in WordPress.
WP-login handles login, logout, registration, password reset and retrieval. Assuming you want to change the front-end login page. There are many plugins to do this easily. You can safely use the following code to redirect custom login page WordPress:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function custom_login_page() { $new_login_page_url = home_url( '/login/' ); // new custom login page WordPress global $pagenow; if( $pagenow == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') { wp_redirect($new_login_page_url); exit; } } if(!is_user_logged_in()){ add_action('init','custom_login_page'); } |
This code snippet will:
1. Redirect all website visitors to new login page.
2. Logout will work without any problem
3. On your custom login page you will have to create custom login , registration and password reset forms, However your custom forms can safely post data to wp-login.php as post requests are not redirected.
How to redirect custom login page WordPress
The article was published on November 6, 2016 @ 5:46 PM
Generic post. I will be dealing with many of these issues as well.
Excellent post. I will be dealing with many of these issues as well..
Hello there! I just wish to give you a big thumbs up. I will be coming back to your website for more soon.
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. It is extremely helpful for me.