[insert_php]
$err = ”;
$success = ”;
global $wpdb;
if(isset($_POST[‘task’]) && $_POST[‘task’] == ‘update’ ) {
$email = $wpdb->escape(trim($_POST[’email’]));
$user = get_user_by( ’email’, $email );
if( $email == “”) {
$err = ‘Email Cant be empty!’;
}
else if (!$user){
$err = ‘Email not registered!’;
}
else {
$user_id = $user->id;
$validity = wp_generate_uuid4();
update_user_meta( $user_id, ‘validity’, $validity );
$subject = “Password Recovery”;
$message = “Please follow the following link to change your password https://tenders.com.ng/change-password?email=”.$email.’&validity=’.$validity;
wp_mail( $email, $subject, $message );
$success = ‘Check your email to continue’;
}
}
[/insert_php]
PASSWORD RESET FORM
[insert_php]
if(! empty($err) ) : echo ”.’
‘.$err.’
‘.”; endif; [/insert_php]
[insert_php] if(! empty($success) ) : echo ”.’
‘.$success.’
‘.”; endif;
get_header();
[/insert_php]