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. WordPress URL Rewrite not working
  6. Displaying a WooCommerce product via PHP
  7. WP E-commerce: Showing 3 random products from current category when viewing product
  8. Woocommerce -How to set product regular price default
  9. Change the footer text on the login page
  10. Changing user_nicename
  11. How to place login logout link on menu that redirects users back to current page?
  12. How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
  13. How to resolve error “Cookies are blocked due to unexpected output.”?
  14. Woocommerce price including tax with formatting from options
  15. Constructing a custom login form using ajax
  16. automated tests as a user?
  17. Woocommerce Custom CSV export
  18. Check if user is logged in when clicking certain links on certain pages
  19. PHP If user is logged in & on home page redirect
  20. WordPress shows registration link for non logged users
  21. Creating login session via CURL
  22. WP_cron won’t trigger my action
  23. Adding a div at the bottom of a sidebar
  24. Recovering WP Login Credintials in Code?
  25. How to run JS, PHP and etc. inside WP post?
  26. WordPress custom login form using Ajax
  27. How to: PHP Log Out Link?
  28. Why is my cookie not unsetting upon logout? [closed]
  29. User management system similar to wordpress one?
  30. WordPress plugin/code to hide all things related of a user from the public
  31. Programmatic Login from 3rd Party site
  32. How to debug my custom login form looping intermittently
  33. getting logged in user info (wp-load.php) from parent directory
  34. Problem with login form
  35. Large Woocommerce Site (83,000 items), What Can I Do? [closed]
  36. showing 2 prices wholesale and normal
  37. How can I hide that I Use WordPress (with W3 Total Cache)
  38. WooCommerce Tabs [closed]
  39. Should `wp_login` be used since it’s deprecated?
  40. How to redirect users based on role and content of redirect_to?
  41. How to display login form anywhere, when user isn’t logged in, without redirecting?
  42. How can I open up my administrative panel to everyone?
  43. How to solve Woocommerce Memory Limit
  44. Get ‘Headers already sent’ error for the plugin I am creating when I try to login
  45. Why doesn’t PhotoSmash plugin play well with wp_query?
  46. How can I add a new row in a separate database when someone registers via WordPress?
  47. How to allow download url redirection only if user logged in WordPress site?
  48. One account with multiple logins
  49. I installed WordPress locally now how do I login?
  50. If user is logged in not working
  51. Change homepage content if user is logged in – BuddyPress
  52. Show login greeting above sub-menu links?
  53. Woocommerce getting top level category parent and make all sub categories have the same template and menu
  54. feedburner plugin for WP 3.5
  55. Display additional page templates and a sidebar on plugin activation
  56. is_user_logged_in returning nothing on custom page
  57. How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
  58. Help with accessing wp-admin page and resolving error messages
  59. Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
  60. Plugin or ways to limit number of users logging in the website,
  61. Can’t log in to WordPress wp-admin after adding code to functions.php
  62. Custom fields not showing up in the user info (PaidMembershipsPro)
  63. Check if user had autologin & if so, logout
  64. Admin Panel 404 Error after login
  65. Log out without confirmation request (nonce)
  66. Which membership plugin for a simple sign in? Personal areas for customers
  67. Call WP Rest-Api to GET /users/me returned NOTHING in console
  68. Infinite loop when logging out using custom login form
  69. Get WordPress username to customize url
  70. Menu not updating for logged in users after redirect
  71. how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
  72. Issues adding Recaptcha v3 to WordPress Registration
  73. Display specific page if user signed in
  74. Change Login or Logout text based on status
  75. Redirecting the lost password page request when using a custon login page
  76. How do I send a POST request with params with WordPress REST API
  77. wp-login.php?redirect_to=https problem
  78. Creating a WordPress addon for ContactForm7 submission (.XML file export)
  79. is_user_logged_in() not working in homepage
  80. Adding a sidebar to wp-login.php
  81. What is the best practice for restricting a section to logged in users?
  82. List users in a dropdown for login
  83. divide custom field values in div every two values
  84. WordPress plugin creating sidebar on the theme/page
  85. White screen after login attempt
  86. WordPress and magic quotes
  87. How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
  88. WordPress Pages into Sections edit.php PHP hack
  89. Advice on setting up private site
  90. WordPress: Create A Widget to Accompany Plugin
  91. PHP Syntax getting PHP terms
  92. How to replace wp-admin login page to another location?
  93. Get Products within Current Product Category
  94. Check user last login date
  95. what is %variable% in a wordpress plugin? [closed]
  96. How do I do so that people can register on my wordpress site?
  97. wp_login_url always redirects me to wp-admin
  98. I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
  99. change div text and link for logged in users
  100. wp-login – unable to redirect user to a custom login url
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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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