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

2 Answers 2

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

I used the code you have successfully, but without a login on the landing page. Instead, I included a link to the wp-login.php which I've branded using WPF-Login. Could you not do this instead?

share|improve this answer
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  TheDeadMedic May 31 at 7:42

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.