Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

woocommerce and is_user_logged_in() if not redirect to homepage

You are going to want to insert your code at the top of the page templates for the Woo pages you would like the redirect to affect rather than the functions file. So for example if you want to redirect users when they try to access an individual product page you could put it at the top of the plugins->woocommerce->templates->single-product.php page.

When editing templates though I would recommend making a copy and placing it in your theme directory, so that when Woo updates it will not override any changes you made. So for the example I gave above (applied to my theme). I would copy single-product.php and place it in the themes->agency file and then make the changes to that file, there. Your theme will then always use that file before the one in the Woo template file.

Related Posts:

  1. User registration followed by automatic login
  2. WordPress and magic quotes
  3. Reposition WooCommerce breadcrumb outside of wrapper content
  4. Adding “Remember Me” in custom login
  5. How to change the wp-login.php page title?
  6. How build a custom login/register form with error handling?
  7. WordPress URL Rewrite not working
  8. Displaying a WooCommerce product via PHP
  9. Remove admin bar for subscribers
  10. WP E-commerce: Showing 3 random products from current category when viewing product
  11. Woocommerce -How to set product regular price default
  12. Change the footer text on the login page
  13. Changing user_nicename
  14. How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
  15. How can I make content disappear when a user logs in?
  16. WordPress widget in custom theme
  17. WordPress 4 invalid username special charachters issue
  18. How to place login logout link on menu that redirects users back to current page?
  19. How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
  20. Bulk Image upload and one image for each post?
  21. How to resolve error “Cookies are blocked due to unexpected output.”?
  22. Woocommerce price including tax with formatting from options
  23. Using a nonce in a Custom Login Form
  24. Constructing a custom login form using ajax
  25. automated tests as a user?
  26. Remove username in emails or swap username for email
  27. Woocommerce Custom CSV export
  28. WooCommerce – Fixed quantity of a product [closed]
  29. Check if user is logged in when clicking certain links on certain pages
  30. PHP If user is logged in & on home page redirect
  31. WordPress shows registration link for non logged users
  32. Creating login session via CURL
  33. WP_cron won’t trigger my action
  34. Admin username and password
  35. How to allow download url redirection only if user logged in WordPress site?
  36. One account with multiple logins
  37. Lost in trying to create user database system
  38. Shortcode to log user into current URL
  39. PHP getting error when trying to access WP-Admin Dashboard
  40. I installed WordPress locally now how do I login?
  41. If user is logged in not working
  42. Change homepage content if user is logged in – BuddyPress
  43. Show login greeting above sub-menu links?
  44. Woocommerce getting top level category parent and make all sub categories have the same template and menu
  45. feedburner plugin for WP 3.5
  46. Display additional page templates and a sidebar on plugin activation
  47. is_user_logged_in returning nothing on custom page
  48. How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
  49. Make separate text boxes for separate WordPress Custom Fields
  50. Help with accessing wp-admin page and resolving error messages
  51. Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
  52. Plugin or ways to limit number of users logging in the website,
  53. Can’t log in to WordPress wp-admin after adding code to functions.php
  54. Custom fields not showing up in the user info (PaidMembershipsPro)
  55. Check if user had autologin & if so, logout
  56. Refresh page after login with litespeed cache
  57. Redirect after login depending on the URL
  58. Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
  59. Redirecting the lost password page request when using a custon login page
  60. How do I send a POST request with params with WordPress REST API
  61. wp-login.php?redirect_to=https problem
  62. Creating a WordPress addon for ContactForm7 submission (.XML file export)
  63. is_user_logged_in() not working in homepage
  64. Check if a user is logged into my WordPress site which is on a different server
  65. Newbie question. Login/Registration. New PHP page
  66. Adding a sidebar to wp-login.php
  67. What is the best practice for restricting a section to logged in users?
  68. List users in a dropdown for login
  69. divide custom field values in div every two values
  70. Not logged in when using http
  71. add bootstrap modal after login in wordpress
  72. WordPress plugin creating sidebar on the theme/page
  73. White screen after login attempt
  74. WordPress and magic quotes
  75. How to get WordPress Adminmenu items?
  76. How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
  77. Simple tree display of WordPress menu
  78. WordPress Pages into Sections edit.php PHP hack
  79. Advice on setting up private site
  80. WordPress Plugin Receive a Link
  81. WordPress: Create A Widget to Accompany Plugin
  82. Redirect users not logged in to the standard login page (and back) from some posts and pages
  83. How can I list only Subcategories in Woocommerce
  84. PHP Syntax getting PHP terms
  85. Masking external links with internal link for member-only
  86. How to replace wp-admin login page to another location?
  87. Get Products within Current Product Category
  88. Check user last login date
  89. what is %variable% in a wordpress plugin? [closed]
  90. Prevent users from display default wordpress login form
  91. login redirect based on user role not work as expected
  92. How to change wp-admin and wp-login urls
  93. How do I do so that people can register on my wordpress site?
  94. wp_login_url always redirects me to wp-admin
  95. I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
  96. change div text and link for logged in users
  97. wp-login – unable to redirect user to a custom login url
  98. Redirect to current URL and append specified URL parameter on unsuccessful login through Elementor login form widget
  99. change Dashboard default page on login
  100. Can’t programmatically log user in php
Categories PHP Tags login, membership, php, plugins
Create a Meta Box in the Admin User Screen?
How do I copy my Parent Templates to my Child Templates?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress