Support » Plugin: WooCommerce » redirect if user is not logged in.

  • 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

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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..


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



    Forum Moderator

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘redirect if user is not logged in.’ is closed to new replies.