Categories

Friday, November 22, 2024
#919814419350 therichposts@gmail.com
PhpWordpress Tricks

Send Forgot Password Email WordPress

How to add custom meta title and meta description in Wordpress?

Send Forgot Password Email Wordpress

Hello, welcome to therichpost.com. In this post, I will tell you How to Send Forgot Password Email WordPress? WordPress is the best cms. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress.

In this post, I have made custom code for Send Forgot Password Email WordPress and you can add this into your wordpress forgot password template page.

If user forgot his/her password then we can use this code and send user password to user email.

And Now Final, here is the code for Send Forgot Password Email WordPress and you can add this code into your wordpress theme’s template file:

$random_password = wp_generate_password( 12, false );
$user = get_user_by( ’email’, $email );
$update_user = wp_update_user( array (
‘ID’ => $user->ID,
‘user_pass’ => $random_password
)
);
if( $update_user ) {
$to = $email;
$subject = ‘Your new password’;
$sender = get_option(‘name’);
$message = ‘Your new password is: ‘.$random_password;
$headers[] = ‘MIME-Version: 1.0’ . “\r\n”;
$headers[] = ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
$headers[] = “X-Mailer: PHP \r\n”;
$headers[] = ‘From: ‘.$sender.’ < ‘.$email.’>’ . “\r\n”;
$mail = wp_mail( $to, $subject, $message, $headers );
}

There are so many tricks in wordpress and I will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.