Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question is an exact duplicate of:

I am building my website on Wordpress and I have created my custom login page.But for a post when an user comments and other nonlogged see the comment with along with a line down "Login to reply".And when the user clicks on that"Login" from "Login to reply" it redirects to wp-login.php.So how to redirect users to custom login page when "login to reply" for a post is clicked on wordpress instead of wp-login.php.

share|improve this question

marked as duplicate by t f, kaiser Feb 16 at 22:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 1 down vote accepted

You need to redirect everytime WordPress looks for wp-login.php.

You can do the same by using the below in your active theme's functions.php file.

function redirect_login_page(){

    // Store for checking if this page equals wp-login.php
    $page_viewed = basename( $_SERVER['REQUEST_URI'] );

    // permalink to the custom login page
    $login_page  = get_permalink( 'CUSTOM_LOGIN_PAGE_ID' );

    if( $page_viewed == "wp-login.php" ) {
        wp_redirect( $login_page );
        exit();
    }
}

add_action( 'init','redirect_login_page' );
share|improve this answer
    
thanks for your help. I have one thing to ask you. I have renamed wp-login.php with name wp-login.php plugin. So shall I use that renamed name in that code or wp-login? –  user3187719 Jan 29 at 7:21
    
Please never make changes to the core files, as you will loose all these changes on upgrade and wp-login.php is a core file –  Maruti Mohanty Jan 29 at 7:23
    
No I just did with a plugin. When I deactivates the plugin, it restores to normal. So please tell me what use renamed wp-login.php or wp-login.php. –  user3187719 Jan 29 at 7:27
    
I am not sure what you are saying, but the base line is you should try your best not to modify core files. –  Maruti Mohanty Jan 29 at 7:30
    
I am still not sure whats the confusion, you pasted the same code that i have put as the answer –  Maruti Mohanty Jan 29 at 7:38

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