I want to achieve that when the user registers on my website, I send him to a specific page, and without automatically logging in.
When we do not register on a WordPress site, we are registered and sent an email to add a password, since I have it configured in the WooCommerce preferences:
WooCommerce => Accounts and Privacy.
Searching, I came across a function that ensures that when the user enters their email in the registration input, they are not automatically logged in. Firstly, when doing this, it took me to the page that I have assigned, where I explain to the user to check his email, but I have discovered that the WordPress email for the user to add a password is not arriving.
This prevents the user from logging in, even though they successfully logged into the WordPress dashboard. See the function that it uses and that now prevents the mail from being sent to the user to establish the password.
How can I ensure that the user does not log in automatically and that the mail arrives to the user?
Can I get it by modifying this function or do I need another way to do it?
function redirect_after_register() {
wp_logout();
wp_redirect( home_url("sigue-las-instrucciones") );
exit();
}
add_action('user_register', 'redirect_after_register');
They told me that maybe it could be that the priority of the hook breaks the session before sending the mail, and try to delay it with this advice:
add_action('user_register', 'redirect_after_register', 99);
But it doesn't work either, the email to add a password does not reach the user
I have also tried several plugins to check (Email Log , Check & Log Email ) the Log of the emails and they do not show any output message