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 a condition such as the following:

1) User is logged. Select Page Shop and displays all content. 2) If user is not logged. Select Shop page, they are redirected to another page, for example Sign Up page.

I hope it is possible. I have tried many plugins but failed. At the moment the only one that works with WooCommerce is s2Member, but it is overkill for my purpose.

Thanks in advance for any help.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You can do this by using

1) is_shop fx

2) template_redirect action hook

3) wp_safe_redirect fx

function ravs_shop_for_login_user(){
  //check user in shop page and not login
  if( is_shop() && ! is_user_logged_in() )
    wp_safe_redirect( home_url() );// enter your url here where you want to redirect page if user on shop page and not registered

Note paste this code in functions.php.currently visiter redirect to home page if not registered,provide any url in wp_safe_redirect fx where you want to user redirect.

share|improve this answer
Hello Ravs, it works fine but I have a little problem with WPML and URL 1) Language site English. User selects Shop, redirect page is "mypagetest", then: testsite.com/mypagetest Ok, it works. 2) Website Language Italian. User selects Shop, redirect page is: testsite.com/it/mypagetest URL error –  user36474 Aug 12 '13 at 12:46
do you have live site ? –  Ravs Aug 12 '13 at 14:56
try this wpml.org/documentation/support/… –  Ravs Aug 12 '13 at 15:15
I'm sorry, It works, it was just a caching issue and I also updated the permalinks. Thanks again for your great help. –  user36474 Aug 12 '13 at 16:11
add comment

Past this code in your Page.php file in your theme. it should do what you need.

if (is_page('shop') && is_user_logged_in()) { // right the title of the page intead the "shop"
     header('Location: wp-login.php?action=register');   // here you can add the url you want to redirect user to it
share|improve this answer
add comment

Your Answer


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.