On my website I have removed wp-login.php to disable the login from default wordpress login window. Then I installed Social Login plugin, users are able to Login properly by using this plugin. But if they click on Logout button, they will be taking to the 404 page, since Logout URL is nothing but a parameter pass to wp-login.php page. So please suggest me a solution, where I can use wp-login.php page only for Logout process. Login and Password Reset should not work.

Sorry for the lengthy query, but I am in urgent need. Thanks in advance.

  • Do they successfully log out before redirecting to 404 page? Commented Jan 12, 2014 at 18:54
  • @RahilWazir: No, they don't. If they click browser back button and do the refresh they can see dashboard as is.
    – Hrishi
    Commented Jan 12, 2014 at 18:59

1 Answer 1


WordPress has hooks so you don't need to actually remove wp-login.php. login_head fires before any HTML is rendered for the login form, and wp_logout fires after the login session has been destroyed. You can put this code in a custom plugin or in your theme's functions.php file to let logout requests continue working but block everything else.

// Allow logout actions but redirect to the home page for all other wp-login.php requests
add_action( 'login_head', 'redirect_home_on_login_form' );
function redirect_home_on_login_form() {
    if ( ! isset( $_REQUEST['action'] ) || 'logout' !== $_REQUEST['action'] ) {
        wp_redirect( home_url( '/' ) );

// wp_logout fires after the user's login cookies have been removed
add_action( 'wp_logout', 'redirect_home_on_logout' );
function redirect_home_on_logout() {
    wp_redirect( home_url( '/' ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.