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:

Join My Newsletter

Get expert tips, handy tools, and helpful tutorials delivered straight to your inbox absolutely free.

NewsLetter Form

Your privacy is important to me. Rest assured, your email address will remain completely confidential and will not be shared with any third party