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 would like to be able to force any un-registered users to the /welcome page - Currently I have set up the following:

if ( trim( $_SERVER['REQUEST_URI'], '/' ) != 'welcome' && ! is_user_logged_in() ) {

wp_redirect( home_url( 'welcome' ), 301 );

exit;

}

This automatically re-directs visitors to the /welcome page. On the welcome page I have a login form, however the users cannot login because it re-directs them back to the welcome page after they hit the submit button. How can I set it up so where they can login through the welcome page and then be re-directed to the homepage after a successful login?

share|improve this question
add comment

1 Answer

Try this: Paste it on functions.php (not tested)

add_action('template_redirect', 'my_user_redirect');

function my_user_redirect(){
  if(!is_user_logged_in()){ // only redirect use not logged in
    wp_redirect( home_url( 'welcome' ), 301 );
    exit;
  }
}

Let me know if it worked.

share|improve this answer
    
This did not work unfortunately. –  icemanhx Dec 15 '12 at 11:10
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.