0

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?

0

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.

| improve this answer | |
  • This did not work unfortunately. – icemanhx Dec 15 '12 at 11:10
0

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?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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