Replace the Default WordPress Login Page with a Custom Login Page | PHP Code Snippet

Replace the Default WordPress Login Page with a Custom Login Page | PHP Code Snippet

Copy and insert this php code to your code snippet plugin to redirect your default WP Login page.

// Disable wp login
function custom_login_page() {
$new_login_page_url = home_url( '/login/' ); // new login page
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');
}
Share Post: