/app/model/communication/class-ms-model-communication-resetpass.php

  1. <?php 
  2. /** 
  3. * Communication model - user forgot password. 
  4. * Triggered when user requests a reset-password email via the M2 
  5. * Forgot Password form. 
  6. * 
  7. * Persisted by parent class MS_Model_CustomPostType. 
  8. * 
  9. * @since 1.0.2.3 
  10. * @package Membership2 
  11. * @subpackage Model 
  12. */ 
  13. class MS_Model_Communication_Resetpass extends MS_Model_Communication { 
  14.  
  15. /** 
  16. * Communication type. 
  17. * 
  18. * @since 1.0.0 
  19. * @var string The communication type. 
  20. */ 
  21. protected $type = self::COMM_TYPE_RESETPASSWORD; 
  22.  
  23. /** 
  24. * Get communication description. 
  25. * 
  26. * @since 1.0.0 
  27. * @return string The description. 
  28. */ 
  29. public function get_description() { 
  30. return sprintf( 
  31. __( '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' ),  
  32. '<code>' . self::COMM_VAR_RESETURL . '</code>' 
  33. ); 
  34.  
  35. /** 
  36. * Communication default communication. 
  37. * 
  38. * @since 1.0.0 
  39. */ 
  40. public function reset_to_default() { 
  41. parent::reset_to_default(); 
  42.  
  43. $this->subject = sprintf( 
  44. __( 'Reset your password for %s', 'membership2' ),  
  45. self::COMM_VAR_BLOG_NAME 
  46. ); 
  47. $this->message = self::get_default_message(); 
  48. $this->enabled = false; 
  49.  
  50. do_action( 
  51. 'ms_model_communication_reset_to_default_after',  
  52. $this->type,  
  53. $this 
  54. ); 
  55.  
  56. /** 
  57. * Get default email message. 
  58. * 
  59. * @since 1.0.0 
  60. * @return string The email message. 
  61. */ 
  62. public static function get_default_message() { 
  63. $subject = sprintf( 
  64. __( 'Hi %1$s, ', 'membership2' ),  
  65. self::COMM_VAR_USERNAME 
  66. ); 
  67. $body_notice = sprintf( 
  68. __( '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' ),  
  69. '<br><br>' . self::COMM_VAR_BLOG_URL . '<br>' . 
  70. sprintf( __( 'Your username: %s', 'membership2' ), self::COMM_VAR_USERNAME ) . '<br><br>',  
  71. '<br><br><a href="' . self::COMM_VAR_RESETURL . '">' . __( 'Click here to reset your password', 'membership2' ) . '</a><br>' . self::COMM_VAR_RESETURL . '<br>' 
  72. ); 
  73.  
  74. $html = sprintf( 
  75. '<h2>%1$s</h2><br /><br />%2$s',  
  76. $subject,  
  77. $body_notice 
  78. ); 
  79.  
  80. return apply_filters( 
  81. 'ms_model_communication_resetpassword_get_default_message',  
  82. $html 
  83. ); 
  84.  
  85. /** 
  86. * Process communication registration. 
  87. * 
  88. * @since 1.0.0 
  89. */ 
  90. public function process_communication( $event, $subscription ) { 
  91. do_action( 
  92. 'ms_model_communication_resetpassword_process_before',  
  93. $subscription,  
  94. $event,  
  95. $this 
  96. ); 
  97.  
  98. // Flag if we sent the customized reset password email. 
  99. if ( $this->send_message( $subscription ) ) { 
  100. add_action( 'ms_sent_reset_password_email', '__return_true' ); 
  101.  
  102. do_action( 
  103. 'ms_model_communication_resetpassword_process_after',  
  104. $subscription,  
  105. $event,  
  106. $this 
  107. ); 
.