MS_Model_Communication_Resetpass

Communication model - user forgot password.

Defined (1)

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

/app/model/communication/class-ms-model-communication-resetpass.php  
  1. class MS_Model_Communication_Resetpass extends MS_Model_Communication { 
  2.  
  3. /** 
  4. * Communication type. 
  5. * @since 1.0.0 
  6. * @var string The communication type. 
  7. */ 
  8. protected $type = self::COMM_TYPE_RESETPASSWORD; 
  9.  
  10. /** 
  11. * Get communication description. 
  12. * @since 1.0.0 
  13. * @return string The description. 
  14. */ 
  15. public function get_description() { 
  16. return sprintf( 
  17. __( 'Reset-Password email sent to the user when the requests a new password via the "Forgot Password" form.<br>Note that this email must include the variable %s to allow the member to reset his password.', 'membership2' ),  
  18. '<code>' . self::COMM_VAR_RESETURL . '</code>' 
  19. ); 
  20.  
  21. /** 
  22. * Communication default communication. 
  23. * @since 1.0.0 
  24. */ 
  25. public function reset_to_default() { 
  26. parent::reset_to_default(); 
  27.  
  28. $this->subject = sprintf( 
  29. __( 'Reset your password for %s', 'membership2' ),  
  30. self::COMM_VAR_BLOG_NAME 
  31. ); 
  32. $this->message = self::get_default_message(); 
  33. $this->enabled = false; 
  34.  
  35. do_action( 
  36. 'ms_model_communication_reset_to_default_after',  
  37. $this->type,  
  38. $this 
  39. ); 
  40.  
  41. /** 
  42. * Get default email message. 
  43. * @since 1.0.0 
  44. * @return string The email message. 
  45. */ 
  46. public static function get_default_message() { 
  47. $subject = sprintf( 
  48. __( 'Hi %1$s, ', 'membership2' ),  
  49. self::COMM_VAR_USERNAME 
  50. ); 
  51. $body_notice = sprintf( 
  52. __( 'Someone requested that the password be reset for the following account: %sIf this was a mistake, just ignore this email and nothing will happen.%s', 'membership2' ),  
  53. '<br><br>' . self::COMM_VAR_BLOG_URL . '<br>' . 
  54. sprintf( __( 'Your username: %s', 'membership2' ), self::COMM_VAR_USERNAME ) . '<br><br>',  
  55. '<br><br><a href="' . self::COMM_VAR_RESETURL . '">' . __( 'Click here to reset your password', 'membership2' ) . '</a><br>' . self::COMM_VAR_RESETURL . '<br>' 
  56. ); 
  57.  
  58. $html = sprintf( 
  59. '<h2>%1$s</h2><br /><br />%2$s',  
  60. $subject,  
  61. $body_notice 
  62. ); 
  63.  
  64. return apply_filters( 
  65. 'ms_model_communication_resetpassword_get_default_message',  
  66. $html 
  67. ); 
  68.  
  69. /** 
  70. * Process communication registration. 
  71. * @since 1.0.0 
  72. */ 
  73. public function process_communication( $event, $subscription ) { 
  74. do_action( 
  75. 'ms_model_communication_resetpassword_process_before',  
  76. $subscription,  
  77. $event,  
  78. $this 
  79. ); 
  80.  
  81. // Flag if we sent the customized reset password email. 
  82. if ( $this->send_message( $subscription ) ) { 
  83. add_action( 'ms_sent_reset_password_email', '__return_true' ); 
  84.  
  85. do_action( 
  86. 'ms_model_communication_resetpassword_process_after',  
  87. $subscription,  
  88. $event,  
  89. $this 
  90. );