PluginProbe
Tutor LMS – eLearning and online course solution / 3.7.2
Tutor LMS – eLearning and online course solution v3.7.2
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
← All changes | classes/FormHandler.php +60 -7 4.0.03.7.2 View file →
@@ -29,8 +29,10 @@
29 29 */
30 30 public function __construct() {
31 31 add_action( 'tutor_action_tutor_retrieve_password', array( $this, 'tutor_retrieve_password' ) );
32 32 add_action( 'tutor_action_tutor_process_reset_password', array( $this, 'tutor_process_reset_password' ) );
33 +
34 + add_action( 'tutor_reset_password_notification', array( $this, 'reset_password_notification' ), 10, 2 );
33 35 add_filter( 'tutor_lostpassword_url', array( $this, 'lostpassword_url' ) );
34 36 }
35 37
36 38 /**
@@ -36,9 +38,8 @@
36 38 /**
37 39 * Retrieve Password
38 40 *
39 41 * @since 1.4.3
40 - *
41 42 * @return void|bool
42 43 */
43 44 public function tutor_retrieve_password() {
44 45 tutils()->checking_nonce();
@@ -103,15 +104,31 @@
103 104 tutor_flash_set( 'danger', $allow->get_error_message() );
104 105 return false;
105 106 }
106 107
107 - $errors = retrieve_password();
108 - if ( is_wp_error( $errors ) ) {
109 - tutor_flash_set( 'danger', $errors->get_error_message() );
110 - return false;
111 - }
108 + // Get password reset key (function introduced in WordPress 4.4).
109 + $key = get_password_reset_key( $user_data );
112 110
113 - $html = '<p> ' . __( "We've sent an email to this account's email address. Click the link in the email to reset your password. If you don't see the email, check other places it might be, like your junk, spam, social, promotion or others folders.", 'tutor' ) . '</p>';
111 + // Send email notification.
112 + do_action( 'tutor_reset_password_notification', $user_login, $key );
113 + }
114 +
115 + /**
116 + * Send notification for rest password
117 + *
118 + * @since 1.4.3
119 + *
120 + * @param string $user_login username.
121 + * @param string $reset_key reset key.
122 + *
123 + * @return void
124 + */
125 + public function reset_password_notification( $user_login = '', $reset_key = '' ) {
126 + $this->send_notification( $user_login, $reset_key );
127 +
128 + $html = '<h3>' . __( 'Check your E-Mail', 'tutor' ) . '</h3>';
129 + $html .= '<p> ' . __( "We've sent an email to this account's email address. Click the link in the email to reset your password.", 'tutor' ) . '</p>';
130 + $html .= '<p>' . __( " If you don't see the email, check other places it might be, like your junk, spam, social, promotion or others folders.", 'tutor' ) . '</p>';
114 131 tutor_flash_set( 'success', $html );
115 132 }
116 133
117 134 /**
@@ -175,8 +192,44 @@
175 192
176 193 wp_safe_redirect( tutor_utils()->tutor_dashboard_url() );
177 194 exit;
178 195 }
196 + }
197 +
198 + /**
199 + * Send Password Reset E-Mail to user.
200 + * We are sending directly right now, later we will introduce centralised E-Mail notification System...
201 + *
202 + * @since 1.4.3
203 + *
204 + * @param string $user_login login username.
205 + * @param string $reset_key password reset key.
206 + *
207 + * @return void
208 + */
209 + public function send_notification( $user_login, $reset_key ) {
210 +
211 + $user_data = get_user_by( 'login', $user_login );
212 +
213 + $variable = array(
214 + 'user_login' => $user_login,
215 + 'reset_key' => $reset_key,
216 + 'user_id' => $user_data->ID,
217 + );
218 +
219 + $html = tutor_get_template_html( 'email.send-reset-password', $variable );
220 + /* translators: %s: site name */
221 + $subject = sprintf( __( 'Password Reset Request for %s', 'tutor' ), get_option( 'blogname' ) );
222 +
223 + $header = 'Content-Type: text/html' . "\r\n";
224 +
225 + add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
226 + add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
227 +
228 + wp_mail( $user_data->user_email, $subject, $html, $header );
229 +
230 + remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
231 + remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
179 232 }
180 233
181 234 /**
182 235 * Get e-mail from address