WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Do they successfully log out before redirecting to 404 page? – rahilwazir Jan 12 '14 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 Jan 12 '14 at 18:59

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( '/' ) );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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