The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Change Admin Login URL

Shared by Darshit Rajyaguru · May 19, 2026 · @init

3 copies
69 views
2 upvotes
Back to Snippets

Redirects wp-login.php access to homepage.

function dr_hide_login_page() {
    $request = basename( $_SERVER['REQUEST_URI'] );

    if ( $request === 'wp-login.php' && ! is_user_logged_in() ) {
        wp_redirect( home_url() );
        exit;
    }
}
add_action( 'init', 'dr_hide_login_page' );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments