PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | features/email-customizer/email-customizer.php +34 -25 3.9.8 → 4.0.3 View file →
@@ -1,5 +1,7 @@
1 1 <?php
2 +// Exit if accessed directly
3 +if ( ! defined( 'ABSPATH' ) ) exit;
2 4
3 5 function wppb_email_customizer_generate_merge_tags( $special_merge_tags = null ){
4 6
5 7 $mustache_vars = array(
@@ -89,8 +91,12 @@
89 91
90 92 $merge_tags[] = array( 'name' => $value['meta-name'], 'type' => 'ec_user_meta', 'label' => $value['field-title'] );
91 93 if( $value['field'] == 'Select' || $value['field'] == 'Select (Multiple)' || $value['field'] == 'Select (Country)' || $value['field'] == 'Select (Currency)' || $value['field'] == 'Checkbox' || $value['field'] == 'Radio' )
92 94 $merge_tags[] = array( 'name' => $value['meta-name'] . '_labels', 'type' => 'ec_user_meta_labels', 'label' => $value['field-title'] . ' Labels' );
95 + elseif( ( $value['field'] == 'Select (CPT)' ) )
96 + $merge_tags[] = array( 'name' => $value['meta-name'].'_cpt_title_link', 'type' => 'user_meta_select_cpt', 'unescaped' => true, 'label' => $value['field-title'] );
97 + elseif( ( $value['field'] == 'Select (Taxonomy)' ) )
98 + $merge_tags[] = array( 'name' => $value['meta-name'].'_taxonomy_title_link', 'type' => 'user_meta_select_taxonomy', 'unescaped' => true, 'label' => $value['field-title'] );
93 99 }
94 100 }
95 101 }
96 102
@@ -98,9 +104,9 @@
98 104 }
99 105
100 106 function wppb_email_customizer_admin_approval_new_user_signup_filter_handler( $default_string, $user_email, $user_password, $email_sent_from, $option_name ){
101 107 $email_customizer_option = get_option( $option_name, 'not_found' );
102 - if ( $email_customizer_option != 'not_found' ){
108 + if ( $email_customizer_option != 'not_found' && !empty( $user_email ) ){
103 109 $user_data = get_user_by( 'email', $user_email );
104 110 $special_merge_tags = ( current_filter() == 'wppb_register_admin_email_message_with_admin_approval' ) ? 'admin_approval' : '';
105 111 wppb_change_email_from_headers();
106 112 return (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags($special_merge_tags), $email_customizer_option, array( 'user_id' => $user_data->ID, 'user_login' => $user_data->user_login, 'user_email' => $user_email, 'user_password' => $user_password, 'user_data' => $user_data, 'email_sent_from' => $email_sent_from ) );
@@ -115,9 +121,9 @@
115 121 } else {
116 122 $email_customizer_option = get_option( $option_name, 'not_found' );
117 123 }
118 124
119 - if ( $email_customizer_option != 'not_found' ){
125 + if ( $email_customizer_option != 'not_found' && !empty( $user_email ) ){
120 126 $user_data = get_user_by( 'email', $user_email );
121 127 wppb_change_email_from_headers();
122 128 return (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags(), $email_customizer_option, array( 'user_id' => $user_data->ID, 'user_login' => $user_data->user_login, 'user_email' => $user_email, 'user_password' => $user_password, 'user_data' => $user_data, 'email_sent_from' => $email_sent_from ) );
123 129 }
@@ -131,9 +137,9 @@
131 137 } else {
132 138 $email_customizer_option = get_option( $option_name, 'not_found' );
133 139 }
134 140
135 - if ( $email_customizer_option != 'not_found' ){
141 + if ( $email_customizer_option != 'not_found' && !empty( $user_email ) ){
136 142 $user_data = get_user_by( 'email', $user_email );
137 143 wppb_change_email_from_headers();
138 144 return (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags(), $email_customizer_option, array( 'user_id' => $user_data->ID, 'user_login' => $user_data->user_login, 'user_email' => $user_email, 'user_password' => $user_password, 'user_data' => $user_data, 'email_sent_from' => $email_sent_from ) );
139 145 }
@@ -170,9 +176,9 @@
170 176 function wppb_email_customizer_password_reset_content_filter_handler( $default_string, $user_id, $user_login, $user_email ) {
171 177 $email_customizer_option = get_option( 'wppb_user_emailc_reset_email_content', 'not_found' );
172 178 $user = new WP_User( $user_id );
173 179 $key = get_password_reset_key( $user );
174 - $url = add_query_arg( array( 'key' => $key, 'login' => $user->user_login ), wppb_curpageurl() );
180 + $url = add_query_arg( array( 'key' => $key, 'login' => urlencode( $user->user_login ) ), wppb_curpageurl() );
175 181
176 182 if( $email_customizer_option != 'not_found' ) {
177 183 wppb_change_email_from_headers();
178 184 return (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags( 'password_reset' ), $email_customizer_option, array( 'user_login' => $user_login, 'reset_key' => $key, 'reset_url' => $url, 'user_email' => $user_email, 'user_id' => $user_id ) );
@@ -183,9 +189,9 @@
183 189
184 190 function wppb_email_customizer_password_reset_title_filter_handler( $default_string, $username ) {
185 191 $email_customizer_option = get_option( 'wppb_user_emailc_reset_email_subject', 'not_found' );
186 192
187 - if( $email_customizer_option != 'not_found' ) {
193 + if( $email_customizer_option != 'not_found' && !empty( $username ) ) {
188 194 wppb_change_email_from_headers();
189 195 $user_info = get_user_by( 'login', $username );
190 196 if( !empty( $user_info->data->user_email ) )
191 197 $user_email = $user_info->data->user_email;
@@ -199,9 +205,9 @@
199 205
200 206 function wppb_email_customizer_password_reset_success_content_filter_handler( $default_string, $username, $new_password, $userID ) {
201 207 $email_customizer_option = get_option( 'wppb_user_emailc_reset_success_email_content', 'not_found' );
202 208
203 - if( $email_customizer_option != 'not_found' ) {
209 + if( $email_customizer_option != 'not_found' && !empty( $userID ) ) {
204 210 $user_info = get_userdata( $userID );
205 211 wppb_change_email_from_headers();
206 212 return (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags(), $email_customizer_option, array( 'user_login' => $username, 'user_password' => $new_password, 'user_id' => $userID, 'user_email' => $user_info->user_email ) );
207 213 }
@@ -211,9 +217,9 @@
211 217
212 218 function wppb_email_customizer_password_reset_success_title_filter_handler( $default_string, $username ) {
213 219 $email_customizer_option = get_option( 'wppb_user_emailc_reset_success_email_subject', 'not_found' );
214 220
215 - if( $email_customizer_option != 'not_found' ) {
221 + if( $email_customizer_option != 'not_found' && !empty( $username ) ) {
216 222 $user_info = get_user_by( 'login', $username );
217 223 /* we could have email instead of username in $username */
218 224 if( !$user_info )
219 225 $user_info = get_user_by( 'email', $username );
@@ -231,9 +237,9 @@
231 237
232 238 function wppb_admin_email_customizer_password_reset_content_filter_handler( $default_string, $username, $new_password, $userID ) {
233 239 $email_customizer_option = get_option( 'wppb_admin_emailc_user_password_reset_email_content', 'not_found' );
234 240
235 - if( $email_customizer_option != 'not_found' ) {
241 + if( $email_customizer_option != 'not_found' && !empty( $userID ) ) {
236 242 $user_info = get_userdata( $userID );
237 243 wppb_change_email_from_headers();
238 244 return (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags(), $email_customizer_option, array( 'user_login' => $username, 'user_password' => $new_password, 'user_id' => $userID, 'user_email' => $user_info->user_email ) );
239 245 }
@@ -243,9 +249,9 @@
243 249
244 250 function wppb_admin_email_customizer_password_reset_title_filter_handler( $default_string, $username ) {
245 251 $email_customizer_option = get_option( 'wppb_admin_emailc_user_password_reset_email_subject', 'not_found' );
246 252
247 - if( $email_customizer_option != 'not_found' ) {
253 + if( $email_customizer_option != 'not_found' && !empty( $username ) ) {
248 254 $user_info = get_user_by( 'login', $username );
249 255 /* we could have email instead of username in $username */
250 256 if( !$user_info )
251 257 $user_info = get_user_by( 'email', $username );
@@ -306,8 +312,11 @@
306 312
307 313 function wppb_email_customizer_change_email_address_content_filter_handler ( $default, $old_user_data, $new_user_data ){
308 314 $email_customizer_option = get_option( 'wppb_user_emailc_change_email_address_content', 'not_found' );
309 315
316 + if( file_exists( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ) )
317 + require_once( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' );
318 +
310 319 if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) ) {
311 320
312 321 $email_change_email = $default;
313 322 $email_content = (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags(), $email_customizer_option, array( 'user_login' => $old_user_data['user_login'], 'user_email' => $old_user_data['user_email'], 'user_id' => $old_user_data['ID'] ) );
@@ -322,9 +331,9 @@
322 331
323 332 function wppb_email_customizer_epaa_title_filter_handler ( $default, $user_id, $approved_field_names, $unapproved_field_names ){
324 333 $email_customizer_option = get_option( 'wppb_user_emailc_epaa_notification_subject', 'not_found' );
325 334
326 - if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) ) {
335 + if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) && !empty( $user_id ) ) {
327 336 $user_info = get_user_by( 'id', $user_id );
328 337 $subject = (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags( 'epaa_notification' ), $email_customizer_option, array( 'user_login' => $user_info->data->user_login, 'user_email' => $user_info->data->user_email, 'user_id' => $user_info->data->ID, 'approved_field_names' => $approved_field_names, 'unapproved_field_names' => $unapproved_field_names ) );
329 338
330 339 wppb_change_email_from_headers();
@@ -336,9 +345,9 @@
336 345
337 346 function wppb_email_customizer_epaa_content_filter_handler ( $default, $user_id, $approved_field_names, $unapproved_field_names ){
338 347 $email_customizer_option = get_option( 'wppb_user_emailc_epaa_notification_content', 'not_found' );
339 348
340 - if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) ) {
349 + if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) && !empty( $user_id ) ) {
341 350 $user_info = get_user_by( 'id', $user_id );
342 351 $email_content = (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags( 'epaa_notification' ), $email_customizer_option, array( 'user_login' => $user_info->data->user_login, 'user_email' => $user_info->data->user_email, 'user_id' => $user_info->data->ID, 'approved_field_names' => $approved_field_names, 'unapproved_field_names' => $unapproved_field_names ) );
343 352
344 353 wppb_change_email_from_headers();
@@ -350,9 +359,9 @@
350 359
351 360 function wppb_admin_email_customizer_epaa_title_filter_handler ( $default, $user_id, $fields, $approve_url ){
352 361 $email_customizer_option = get_option( 'wppb_admin_emailc_epaa_notification_subject', 'not_found' );
353 362
354 - if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) ) {
363 + if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) && !empty( $user_id ) ) {
355 364 $user_info = get_user_by( 'id', $user_id );
356 365 $subject = (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags( 'epaa_notification_admin' ), $email_customizer_option, array( 'user_login' => $user_info->data->user_login, 'user_email' => $user_info->data->user_email, 'user_id' => $user_info->data->ID, 'modified_fields' => $fields, 'approval_url' => $approve_url ) );
357 366
358 367 wppb_change_email_from_headers();
@@ -364,9 +373,9 @@
364 373
365 374 function wppb_admin_email_customizer_epaa_content_filter_handler ( $default, $user_id, $fields, $approve_url ){
366 375 $email_customizer_option = get_option( 'wppb_admin_emailc_epaa_notification_content', 'not_found' );
367 376
368 - if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) ) {
377 + if( $email_customizer_option != 'not_found' && class_exists( 'PB_Mustache_Generate_Template' ) && !empty( $user_id ) ) {
369 378 $user_info = get_user_by( 'id', $user_id );
370 379 $email_content = (string) new PB_Mustache_Generate_Template( wppb_email_customizer_generate_merge_tags( 'epaa_notification_admin' ), $email_customizer_option, array( 'user_login' => $user_info->data->user_login, 'user_email' => $user_info->data->user_email, 'user_id' => $user_info->data->ID, 'modified_fields' => $fields, 'approval_url' => $approve_url ) );
371 380
372 381 wppb_change_email_from_headers();
@@ -597,15 +606,14 @@
597 606
598 607 if( wppb_get_admin_approval_option_value() === 'yes' ){
599 608 if ( isset( $extra_data['user_password'] ) ) {
600 609 global $wpdb;
601 - $search_for_password = $wpdb->get_results(
602 - "
603 - SELECT user_pass
604 - FROM $wpdb->users
605 - WHERE user_pass = '".$extra_data['user_password']."'
606 - "
607 - );
610 +
611 + $search_for_password = $wpdb->get_results( $wpdb->prepare(
612 + "SELECT user_pass FROM $wpdb->users WHERE user_pass = '%s'",
613 + $extra_data['user_password']
614 + ));
615 +
608 616 if( !empty( $search_for_password ) )
609 617 return __( 'Your selected password at signup', 'profile-builder' );
610 618 }
611 619 }
@@ -843,9 +851,10 @@
843 851 * @return string
844 852 */
845 853 function wppb_ec_generate_user_email_change_link( $value, $merge_tag_name, $merge_tag, $extra_data ){
846 854 if ( isset( $extra_data['change_email_url'] ) )
847 - return $extra_data['change_email_url'];
855 +// return $extra_data['change_email_url'];
856 + return '<a href="'. $extra_data['change_email_url'] .'">'. __( 'Change Email Address Link', 'profile-builder' ) .'</a>';
848 857 }
849 858 add_filter( 'mustache_variable_ec_user_email_change_link', 'wppb_ec_generate_user_email_change_link', 10, 4 );
850 859
851 860
@@ -1216,22 +1225,22 @@
1216 1225 $reply_to_email = get_option( 'wppb_emailc_common_settings_from_reply_to_email', 'not_found' );
1217 1226
1218 1227 if ( $reply_to_email != 'not_found' ) {
1219 1228 $reply_to_email = str_replace('{{reply_to}}', get_bloginfo('admin_email'), $reply_to_email );
1220 -
1229 +
1221 1230 if( is_email( $reply_to_email ) )
1222 1231 $sender_email = $reply_to_email;
1223 1232 }
1224 1233
1225 1234 return apply_filters( 'wppb_from_website_email', $sender_email );
1226 -
1235 +
1227 1236 }
1228 1237
1229 1238 // function that filters the From name
1230 1239 function wppb_website_name($site_name){
1231 -
1240 +
1232 1241 $email_from_name = get_option( 'wppb_emailc_common_settings_from_name', 'not_found' );
1233 -
1242 +
1234 1243 if ( $email_from_name != 'not_found' ) {
1235 1244 $email_from_name = str_replace('{{site_name}}', get_bloginfo('name'), $email_from_name );
1236 1245 $site_name = $email_from_name;
1237 1246 }