WooCommerce - excelling eCommerce
[closed] redirect if user is not logged in. (4 posts)

  1. dezahyner
    Posted 1 year ago #

    I have a woocommerce site that I want to redirect users that are not logged in to the login page, but only for one product.

    I have copied the single-product.php to my theme folder and added the following before "get header"

    if( !is_user_logged_in() && $product_id = 7854 ) {

    but... this redirects all product links to login page. I only want one of them to redirect. How can I do this without using a plugin. I want to avoid that.

    Any help would be greatly appreciated


  2. dezahyner
    Posted 1 year ago #

    I also tried......

    if( !is_user_logged_in() && is_product(7854))  {

    and again.. when you click on any product, it redirects to login, even though, I have specified the product id..


  3. photocurio
    Posted 1 year ago #

    Did you fix this? I'm working on a similar problem.

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else's topic.

    I am now closing this 4 month old topic as it references an older version of WordPress.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic