0
I am customizing the password definition email that is sent to the user when they sign up, but when I try to create the password definition link it is not taking the user login, I am using the code below in functions.php
function handle_wp_mail($args) {
if ($args['subject'] == '[SBACV - GO - Sociedade Goiana de Angiologia e Cirurgia Vascular] Seu nome de usuário e senha') {
$wpdb = $GLOBALS['wpdb'];
$email = $args['to'][0];
$user = get_user_by('email', $email);
$key = wp_generate_password(20, false);
require_once(ABSPATH . WPINC . '/class-phpass.php');
$hasher = new PasswordHash(8, true);
$hashed = time() . ':' . $hasher->HashPassword($key);
$wpdb->update($wpdb->users, ['user_activation_key' => $hashed], ['user_login' => $user->user_login]);
$regUrl = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login');
$newMessage = <<<EOT
<h2>Bem vindo a SBACV-GO</h2>
<p></p>
<p>Obrigado por se registrar!</p>
<p><a href="$regUrl">Clique aqui para definir sua senha de acesso.</a></p>
EOT;
$newMail = [
'to' => $args['to'],
'subject' => 'Bem vindo a SBACV-GO',
'headers' => $args['headers'],
'attachments' => $args['attachments'],
'message' => $newMessage,
];
return $newMail;
}
}
add_filter('wp_mail', 'handle_wp_mail');
displays any errors? returns empty? what happens?
– Diego Lela
redirect url: /wp-login.php? action=lostpassword&error=invalidkey error: The link to reset your password seems to be invalid. Request a new link below.
– Renan Hugo
you tried to debug these variables and see if they’re all getting feedback?
– Diego Lela