WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

closed as off-topic by Pieter Goosen, toscho Oct 29 '14 at 11:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

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 ? – Ravinder Kumar Aug 12 '13 at 14:56
try this wpml.org/documentation/support/… – Ravinder Kumar 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

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

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