User registration & user profile – Profile Builder - Version 1.1.57

Version Description

Minor changes to the readme.txt file.

Download this release

Release Info

Developer barinagabriel
Plugin Icon 128x128 User registration & user profile – Profile Builder
Version 1.1.57
Comparing to
See all releases

Code changes from version 1.1.56 to 1.1.57

Files changed (1) hide show
  1. front-end/wppb.recover.password.php +38 -27
front-end/wppb.recover.password.php CHANGED
@@ -4,11 +4,11 @@ function wppb_check_for_unapproved_user($data, $what){
4
  $retMessage = '';
5
  $messageNo = '';
6
 
7
- $wppb_generalSettings = get_option('wppb_general_settings');
8
 
9
- if($wppb_generalSettings['adminApproval'] == 'yes'){
10
 
11
- if ($what == 'user_email'){
12
  require_once(ABSPATH . WPINC . '/ms-functions.php');
13
  $userID = get_user_id_from_string( $data );
14
 
@@ -18,7 +18,7 @@ function wppb_check_for_unapproved_user($data, $what){
18
  }
19
 
20
 
21
- if (wp_get_object_terms( $userID, 'user_status' )){
22
  $retMessage = '<strong>'. __('ERROR', 'profilebuilder') . '</strong>: ' . __('Your account has to be confirmed by an administrator before you can use the "Password Reset" feature.', 'profilebuilder');
23
  $retMessage = apply_filters('wppb_recover_password_unapporved_user', $retMessage);
24
 
@@ -30,6 +30,23 @@ function wppb_check_for_unapproved_user($data, $what){
30
  return $retArray = array(0 => $retMessage, 1 => $messageNo);
31
  }
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  function wppb_front_end_password_recovery(){
35
  $recoverPasswordFilterArray = array();
@@ -70,8 +87,11 @@ function wppb_front_end_password_recovery(){
70
  $requestedUserLogin = $query[0]->user_login;
71
  $requestedUserEmail = $query[0]->user_email;
72
 
 
 
 
73
  //send primary email message
74
- $recoverPasswordFilterArray['userMailMessage1'] = sprintf(__('Someone requested that the password be reset for the following account: <b>%1$s</b><br/>If this was a mistake, just ignore this email and nothing will happen.<br/>To reset your password, visit the following link:%2$s', 'profilebuilder'), $requestedUserLogin, '<a href="'.add_query_arg( array( 'loginName' => $user_login, 'key' => $key ), wppb_curpageurl() ).'">'.add_query_arg( array( 'loginName' => $user_login, 'key' => $key ), wppb_curpageurl() ).'</a>');
75
  $recoverPasswordFilterArray['userMailMessage1'] = apply_filters('wppb_recover_password_message_content_sent_to_user1', $recoverPasswordFilterArray['userMailMessage1'], $requestedUserID, $requestedUserLogin);
76
 
77
  $recoverPasswordFilterArray['userMailMessageTitle1'] = sprintf(__('Password Reset Feature from "%1$s"', 'profilebuilder'), $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES));
@@ -118,16 +138,7 @@ function wppb_front_end_password_recovery(){
118
  $requestedUserEmail = $query[0]->user_email;
119
 
120
  //search if there is already an activation key present, if not create one
121
- $key = $wpdb->get_var( $wpdb->prepare( "SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $requestedUserLogin ) );
122
- if ( empty($key) ) {
123
-
124
- // Generate something random for a key...
125
- $key = wp_generate_password( 20, false );
126
- do_action('wppb_retrieve_password_key', $requestedUserLogin, $key);
127
-
128
- // Now insert the new md5 key into the db
129
- $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $requestedUserLogin));
130
- }
131
 
132
  //send primary email message
133
  $recoverPasswordFilterArray['userMailMessage1'] = sprintf(__('Someone requested that the password be reset for the following account: <b>%1$s</b><br/>If this was a mistake, just ignore this email and nothing will happen.<br/>To reset your password, visit the following link:%2$s', 'profilebuilder'), $requestedUserLogin, '<a href="'.add_query_arg( array( 'loginName' => $requestedUserLogin, 'key' => $key ), wppb_curpageurl() ).'">'.add_query_arg( array( 'loginName' => $requestedUserLogin, 'key' => $key ), wppb_curpageurl() ).'</a>');
@@ -175,29 +186,29 @@ function wppb_front_end_password_recovery(){
175
  $user_info = get_userdata($userID);
176
 
177
  //send secondary mail to the user containing the username and the new password
178
- $recoverPasswordFilterArray['userMailMessage2'] = sprintf(__('You have successfully reset your password to: %1$s', 'profilebuilder'), $new_pass);
179
- $recoverPasswordFilterArray['userMailMessage2'] = apply_filters('wppb_recover_password_message_content_sent_to_user2', $recoverPasswordFilterArray['userMailMessage2'], $loginName);
180
 
181
- $recoverPasswordFilterArray['userMailMessageTitle2'] = sprintf(__('Password Successfully Reset for %1$s on "%2$s"', 'profilebuilder'), $user_info->user_login, $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES));
182
- $recoverPasswordFilterArray['userMailMessageTitle2'] = apply_filters('wppb_recover_password_message_title_sent_to_user2', $recoverPasswordFilterArray['userMailMessageTitle2']);
183
 
184
  //we add this filter to enable html encoding
185
- add_filter('wp_mail_content_type',create_function('', 'return "text/html"; '));
186
  //send mail to the user notifying him of the reset request
187
- if (trim($recoverPasswordFilterArray['userMailMessageTitle2']) != '')
188
- wp_mail($user_info->user_email, $recoverPasswordFilterArray['userMailMessageTitle2'], $recoverPasswordFilterArray['userMailMessage2']);
189
 
190
  //send email to admin
191
- $recoverPasswordFilterArray['adminMailMessage'] = sprintf(__('%1$s has requested a password change via the password reset feature.<br/>His/her new password is:%2$s', 'profilebuilder'), $user_info->user_login, $_POST['passw1']);
192
- $recoverPasswordFilterArray['adminMailMessage'] = apply_filters('wppb_recover_password_message_content_sent_to_admin', $recoverPasswordFilterArray['adminMailMessage']);
193
 
194
- $recoverPasswordFilterArray['adminMailMessageTitle'] = sprintf(__('Password Successfully Reset for %1$s on "%2$s"', 'profilebuilder'), $user_info->user_login, $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES));
195
- $recoverPasswordFilterArray['adminMailMessageTitle'] = apply_filters('wppb_recover_password_message_title_sent_to_admin', $recoverPasswordFilterArray['adminMailMessageTitle']);
196
 
197
 
198
  //we disable the feature to send the admin a notification mail but can be still used using filters
199
  $recoverPasswordFilterArray['adminMailMessageTitle'] = '';
200
- $recoverPasswordFilterArray['adminMailMessageTitle'] = apply_filters('wppb_recover_password_message_title_sent_to_admin', $recoverPasswordFilterArray['adminMailMessageTitle']);
201
 
202
  //we add this filter to enable html encoding
203
  add_filter('wp_mail_content_type',create_function('', 'return "text/html"; '));
4
  $retMessage = '';
5
  $messageNo = '';
6
 
7
+ $wppb_generalSettings = get_option( 'wppb_general_settings' );
8
 
9
+ if( $wppb_generalSettings['adminApproval'] == 'yes' ){
10
 
11
+ if ( $what == 'user_email' ){
12
  require_once(ABSPATH . WPINC . '/ms-functions.php');
13
  $userID = get_user_id_from_string( $data );
14
 
18
  }
19
 
20
 
21
+ if ( wp_get_object_terms( $userID, 'user_status' ) ){
22
  $retMessage = '<strong>'. __('ERROR', 'profilebuilder') . '</strong>: ' . __('Your account has to be confirmed by an administrator before you can use the "Password Reset" feature.', 'profilebuilder');
23
  $retMessage = apply_filters('wppb_recover_password_unapporved_user', $retMessage);
24
 
30
  return $retArray = array(0 => $retMessage, 1 => $messageNo);
31
  }
32
 
33
+ function wppb_retrieve_activation_key( $requestedUserLogin ){
34
+ global $wpdb;
35
+
36
+ $wpdb->get_var( $wpdb->prepare( "SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $requestedUserLogin ) );
37
+ if ( empty($key) ) {
38
+
39
+ // Generate something random for a key...
40
+ $key = wp_generate_password( 20, false );
41
+ do_action('wppb_retrieve_password_key', $requestedUserLogin, $key);
42
+
43
+ // Now insert the new md5 key into the db
44
+ $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $requestedUserLogin));
45
+ }
46
+
47
+ return $key;
48
+ }
49
+
50
 
51
  function wppb_front_end_password_recovery(){
52
  $recoverPasswordFilterArray = array();
87
  $requestedUserLogin = $query[0]->user_login;
88
  $requestedUserEmail = $query[0]->user_email;
89
 
90
+ //search if there is already an activation key present, if not create one
91
+ $key = wppb_retrieve_activation_key( $requestedUserLogin );
92
+
93
  //send primary email message
94
+ $recoverPasswordFilterArray['userMailMessage1'] = sprintf(__('Someone requested that the password be reset for the following account: <b>%1$s</b><br/>If this was a mistake, just ignore this email and nothing will happen.<br/>To reset your password, visit the following link:%2$s', 'profilebuilder'), $requestedUserLogin, '<a href="'.add_query_arg( array( 'loginName' => $requestedUserLogin, 'key' => $key ), wppb_curpageurl() ).'">'.add_query_arg( array( 'loginName' => $requestedUserLogin, 'key' => $key ), wppb_curpageurl() ).'</a>');
95
  $recoverPasswordFilterArray['userMailMessage1'] = apply_filters('wppb_recover_password_message_content_sent_to_user1', $recoverPasswordFilterArray['userMailMessage1'], $requestedUserID, $requestedUserLogin);
96
 
97
  $recoverPasswordFilterArray['userMailMessageTitle1'] = sprintf(__('Password Reset Feature from "%1$s"', 'profilebuilder'), $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES));
138
  $requestedUserEmail = $query[0]->user_email;
139
 
140
  //search if there is already an activation key present, if not create one
141
+ $key = wppb_retrieve_activation_key( $requestedUserLogin );
 
 
 
 
 
 
 
 
 
142
 
143
  //send primary email message
144
  $recoverPasswordFilterArray['userMailMessage1'] = sprintf(__('Someone requested that the password be reset for the following account: <b>%1$s</b><br/>If this was a mistake, just ignore this email and nothing will happen.<br/>To reset your password, visit the following link:%2$s', 'profilebuilder'), $requestedUserLogin, '<a href="'.add_query_arg( array( 'loginName' => $requestedUserLogin, 'key' => $key ), wppb_curpageurl() ).'">'.add_query_arg( array( 'loginName' => $requestedUserLogin, 'key' => $key ), wppb_curpageurl() ).'</a>');
186
  $user_info = get_userdata($userID);
187
 
188
  //send secondary mail to the user containing the username and the new password
189
+ $recoverPasswordFilterArray['userMailMessage2'] = sprintf( __( 'You have successfully reset your password to: %1$s', 'profilebuilder' ), $new_pass );
190
+ $recoverPasswordFilterArray['userMailMessage2'] = apply_filters( 'wppb_recover_password_message_content_sent_to_user2', $recoverPasswordFilterArray['userMailMessage2'], $loginName );
191
 
192
+ $recoverPasswordFilterArray['userMailMessageTitle2'] = sprintf( __('Password Successfully Reset for %1$s on "%2$s"', 'profilebuilder' ), $user_info->user_login, $blogname = wp_specialchars_decode( get_option('blogname'), ENT_QUOTES ) );
193
+ $recoverPasswordFilterArray['userMailMessageTitle2'] = apply_filters( 'wppb_recover_password_message_title_sent_to_user2', $recoverPasswordFilterArray['userMailMessageTitle2'] );
194
 
195
  //we add this filter to enable html encoding
196
+ add_filter( 'wp_mail_content_type',create_function( '', 'return "text/html"; ') );
197
  //send mail to the user notifying him of the reset request
198
+ if ( trim( $recoverPasswordFilterArray['userMailMessageTitle2'] ) != '' )
199
+ wp_mail( $user_info->user_email, $recoverPasswordFilterArray['userMailMessageTitle2'], $recoverPasswordFilterArray['userMailMessage2'] );
200
 
201
  //send email to admin
202
+ $recoverPasswordFilterArray['adminMailMessage'] = sprintf( __( '%1$s has requested a password change via the password reset feature.<br/>His/her new password is:%2$s', 'profilebuilder' ), $user_info->user_login, $_POST['passw1'] );
203
+ $recoverPasswordFilterArray['adminMailMessage'] = apply_filters( 'wppb_recover_password_message_content_sent_to_admin', $recoverPasswordFilterArray['adminMailMessage'] );
204
 
205
+ $recoverPasswordFilterArray['adminMailMessageTitle'] = sprintf( __( 'Password Successfully Reset for %1$s on "%2$s"', 'profilebuilder' ), $user_info->user_login, $blogname = wp_specialchars_decode( get_option('blogname'), ENT_QUOTES ) );
206
+ $recoverPasswordFilterArray['adminMailMessageTitle'] = apply_filters( 'wppb_recover_password_message_title_sent_to_admin', $recoverPasswordFilterArray['adminMailMessageTitle'] );
207
 
208
 
209
  //we disable the feature to send the admin a notification mail but can be still used using filters
210
  $recoverPasswordFilterArray['adminMailMessageTitle'] = '';
211
+ $recoverPasswordFilterArray['adminMailMessageTitle'] = apply_filters( 'wppb_recover_password_message_title_sent_to_admin', $recoverPasswordFilterArray['adminMailMessageTitle'] );
212
 
213
  //we add this filter to enable html encoding
214
  add_filter('wp_mail_content_type',create_function('', 'return "text/html"; '));