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.

I have a custom page called owner-login that has a wp_login_form()

How can I disable wp-login.php so that:

  • when a user writes wp-admin/ it will redirect him to the owner-login (if not logged)
  • when a user writes wp-login.php it will redirect him to the owner-login (logged/not logged)

Generally, I don't want to show wp-login, but to have the functionality for the scripts that require

share|improve this question
    
keep in mind that out of the box WordPress adds pretty permalinks for example.com/admin /dashboard /logout and /login –  Tom J Nowell Jan 28 '13 at 14:08
    
What is the difference between what you want and how things already work? –  s_ha_dum Jan 28 '13 at 14:21
    
My custom page is a template page with wp_login_form(), but on failure or by typing wp-admin/ (!logged in) it shows the plain vanilla wp-login.php page, which I don't want it to be shown. I want it to be redirected to my template page but keep the functionality of wp-login. –  Panagiotis Jan 28 '13 at 21:02
add comment

1 Answer

up vote 0 down vote accepted

Try something similar to this:

function is_login() {
    return in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) );
}
function redirect_login() {
    if ( is_login() ) {
        wp_redirect('http://example.com/customloginpage');
    }
}
add_action( 'init', 'redirect_login' );

You'll need to modify the URL it redirects to, and test thoroughly.

share|improve this answer
add comment

Your Answer

 
discard

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.