I have a woocommerce shop that only allows logged in users to make purchases. I have replaced my add to cart button with a "login" button if the user is not already logged in. This than brings them to the (my-account) page where they can choose to login or register.
However I was wondering if I could take this one step further and make it so wordpress remembers what page the user was on before they entered the login page. And if they login, it will redirect them back to that page.
I found this script which redirects users to the login page if they click on a product/page. And then if they login it takes them back to the page they were trying to enter. This is close to what I want to do, but instead of taking them to the login page before seeing a product. I want them to be able to see the product. Then click a button that takes them to the ((my-account page)) and if they login it redirects them back to the product page.
Redirect user to original url after login?
Any help would be much appreciate. Function, plugins, anything.
Thanks!