Redirect Users to a Specific Product After Login
In this post you will learn how to redirect all users to a product after logging in on the wp-login page. In our example, we want to redirect the users to this product:
To redirect to a product, you need to know the product id and save it in the “$postId” variable, in our case the product id is “29165”. Add the following code with the right product id to your functions.php file:
if(!function_exists('arrow_design_redirect_me_after_login')){ function arrow_design_redirect_me_after_login(){ $postId = 29165; wp_redirect(get_permalink($postId)); exit(); } add_action('wp_login','arrow_design_redirect_me_after_login',10); }
Conclusion
We hope this Redirect Users to a Specific Product After Login post was helpful and you are now able to integrate this also on your website! You can find more articles here:
Read another Woocommerce post : ‘Block Purchase from Logged Out Users‘
Arrow Design, based in Dublin, Ireland, provides quality website design services in Dublin and beyond at affordable prices. If you would like help with implementing the above code, or any wordpress website development project, contact us. We love website design and it shows! We provide custom wordpress plugin development, website design training and lots more.
We do it all, so you don’t have to!
Related Posts
Woocommerce Account Page Hook Guide
In this article you will find a visual hook guide for the Woocommerce Account Pages, like the Login/Register page, the Downloads page or the Orders page.
Woocommerce Single Product Page Hook Guide
In this article you will find a visual hook guide for the Woocommerce Single Product Page. This should help you to quickly and easily find the hook positions on the page.
Woocommerce PHP – Product Categories by Product ID
In this tutorial you will learn how to check if a product is assigned to a tag, a category or a custom taxonomy. You can check if a product is is on the shop page, in the cart, in an order & more.
…We do more, so you can do less 🙂