bb_reset_email

Sends a reset password email.

Description

bb_reset_email( (string) $user_login ); 

Sends an email to the email address specified in the user's profile prompting them to change their password.

Parameters (1)

0. $user_login (string)
The user login.

Usage

  1. if ( !function_exists( 'bb_reset_email' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-users.php'; 
  3.  
  4. // The user login. 
  5. $user_login = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_reset_email($user_login); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-users.php  
  1. function bb_reset_email( $user_login ) 
  2. global $bbdb; 
  3.  
  4. $user_login = sanitize_user( $user_login, true ); 
  5.  
  6. if ( !$user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $user_login ) ) ) { 
  7. return new WP_Error( 'user_does_not_exist', __( 'The specified user does not exist.' ) ); 
  8.  
  9. $resetkey = substr( md5( bb_generate_password() ), 0, 15 ); 
  10. bb_update_usermeta( $user->ID, 'newpwdkey', $resetkey ); 
  11.  
  12. $reseturi = bb_get_uri
  13. 'bb-reset-password.php',  
  14. array( 'key' => $resetkey ),  
  15. ); 
  16.  
  17. $message = sprintf( 
  18. __( "If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!" ),  
  19. $reseturi 
  20. ); 
  21. $message = apply_filters( 'bb_reset_email_message', $message, $user, $reseturi, $resetkey ); 
  22.  
  23. $subject = sprintf( 
  24. __( '%s: Password Reset' ),  
  25. bb_get_option( 'name' ) 
  26. ); 
  27. $subject = apply_filters( 'bb_reset_email_subject', $subject, $user ); 
  28.  
  29. $mail_result = bb_mail
  30. bb_get_user_email( $user->ID ),  
  31. $subject,  
  32. $message 
  33. ); 
  34.  
  35. if ( !$mail_result ) { 
  36. return new WP_Error( 'sending_mail_failed', __( 'The email containing the password reset link could not be sent.' ) ); 
  37.  
  38. return true;