menu

Questions & Answers

Why does WordPress not send the user the email to add a password?

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

enter image description here

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

Comments:
2023-01-19 23:01:11
Before you get too far, is the email not being sent, or is it just not arriving. They are two very different things.
2023-01-19 23:01:11
Which email agent do you use? smtp, mail or sendmail?
2023-01-19 23:01:11
I have installed the Email Log Plugin, and it does not show any outgoing mail. I don't know how I can verify this in more detail. The emails reach the user correctly if I don't have that function, the one I need so that they don't automatically log in after registration. I have not configured any email agent, it is the basic configuration of WordPress. Without this feature, emails to add a password when registering correctly reach the registering user. The problem arises when I put the pair function to redirect the user after registration and no login
Answers(0) :