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 redirect script

function login_redirect() {

global $pagenow;

// Check to see if user in not logged in and not on the login page
if(!is_user_logged_in() && $pagenow != 'wp-login.php')
    // If user is, Redirect to Login form.

add_action( 'wp', 'login_redirect' );`

It works good, however when I click register, I'm redirected to login.

How I can redirect users to wp-login.php or wp-register.php.

P.S wp-register.php is a site of buddypress.

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.