Reset Password

// 1. Define the shortcode: [custom_reset_password] add_shortcode('custom_reset_password', 'custom_reset_password_form');function custom_reset_password_form() { ob_start();// When form is submitted if (isset($_POST['custom_reset_email'])) { $email = sanitize_email($_POST['custom_reset_email']); $user = get_user_by('email', $email);if ($user) { // Generate reset key and link $reset_key = get_password_reset_key($user); $reset_url = site_url("wp-login.php?action=rp&key=$reset_key&login=" . rawurlencode($user->user_login));echo "

✅ A password reset link has been sent to your email address.

";// Send reset link via email wp_mail( $email, 'Reset Your Password', "Hello,\n\nClick the link below to reset your password:\n\n$reset_url" ); } else { echo "

⚠️ This email address is not registered.

"; } }// Display the email input form ?>