PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.11
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.11
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
← All changes | includes/helpers/forms.php +73 -94 1.2.651.2.11 View file →
@@ -6,14 +6,14 @@
6 6 * @package userswp
7 7 *
8 8 * @since 1.0.0
9 9 */
10 -function get_register_form_fields( $form_id = 1 ) {
10 +function get_register_form_fields($form_id = 1) {
11 11 global $wpdb;
12 12 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
13 13 $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras';
14 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT fields.* FROM ' . $table_name . ' fields JOIN ' . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND extras.form_type = 'register' AND extras.form_id=%d AND fields.form_id=%d ORDER BY extras.sort_order ASC", array( 'account', $form_id, $form_id ) ) );
15 - $fields = apply_filters( 'uwp_get_register_form_fields', $fields, $form_id );
14 + $fields = $wpdb->get_results($wpdb->prepare("SELECT fields.* FROM " . $table_name . " fields JOIN " . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND extras.form_type = 'register' AND extras.form_id=%d AND fields.form_id=%d ORDER BY extras.sort_order ASC", array('account', $form_id, $form_id)));
15 + $fields = apply_filters('uwp_get_register_form_fields', $fields, $form_id);
16 16 return $fields;
17 17 }
18 18
19 19 function check_register_form_field( $var ) {
@@ -25,9 +25,9 @@
25 25 $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras';
26 26
27 27 $fields = $wpdb->get_results(
28 28 $wpdb->prepare(
29 - 'select * from ' . $extras_table_name . ' where form_type = %s AND site_htmlvar_name = %s order by sort_order asc',
29 + "select * from " . $extras_table_name . " where form_type = %s AND site_htmlvar_name = %s order by sort_order asc",
30 30 array( 'register', $var )
31 31 )
32 32 );
33 33
@@ -49,9 +49,9 @@
49 49 function get_register_validate_form_fields( $form_id = 1 ) {
50 50 global $wpdb;
51 51 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
52 52 $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras';
53 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT fields.* FROM ' . $table_name . ' fields JOIN ' . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND extras.form_type = 'register' AND fields.field_type != 'fieldset' AND fields.field_type != 'file' AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND extras.form_id = %d AND fields.form_id = %s ORDER BY extras.sort_order ASC", array( 'account', $form_id, $form_id ) ) );
53 + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT fields.* FROM " . $table_name . " fields JOIN " . $extras_table_name . " extras ON extras.site_htmlvar_name = fields.htmlvar_name WHERE fields.form_type = %s AND fields.field_type != 'fieldset' AND fields.field_type != 'file' AND fields.is_active = '1' AND fields.for_admin_use != '1' AND fields.is_register_field = '1' AND fields.form_id = %s ORDER BY extras.sort_order ASC", array( 'account', $form_id ) ) );
54 54 $fields = apply_filters( 'uwp_get_register_validate_form_fields', $fields, $form_id );
55 55
56 56 return $fields;
57 57 }
@@ -68,15 +68,15 @@
68 68 global $wpdb;
69 69 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
70 70 $enable_old_password = uwp_get_option( 'change_enable_old_password', false );
71 71 $user_id = get_current_user_id();
72 - if ( $user_id && 1 == get_user_meta( $user_id, 'is_uwp_social_login_no_password', true ) ) {
72 + if($user_id && 1 == get_user_meta($user_id, 'is_uwp_social_login_no_password', true)){
73 73 $enable_old_password = 0;
74 74 }
75 75 if ( $enable_old_password == '1' ) {
76 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) );
76 + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) );
77 77 } else {
78 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) );
78 + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND field_type != 'fieldset' AND field_type != 'file' AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) );
79 79 }
80 80
81 81 return $fields;
82 82 }
@@ -97,11 +97,11 @@
97 97 $form_id = uwp_get_register_form_id( get_current_user_id() );
98 98 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
99 99 $include_admin_use = apply_filters( 'uwp_account_include_admin_use_only_fields', false );
100 100 if ( $include_admin_use ) {
101 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . ' ORDER BY sort_order ASC', array( 'account', $form_id ) ) );
101 + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . " ORDER BY sort_order ASC", array( 'account', $form_id ) ) );
102 102 } else {
103 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . ' ORDER BY sort_order ASC', array( 'account', $form_id ) ) );
103 + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND is_register_only_field = '0' AND htmlvar_name != 'password' AND form_id = %s" . $extra_where . " ORDER BY sort_order ASC", array( 'account', $form_id ) ) );
104 104 }
105 105
106 106 return $fields;
107 107 }
@@ -118,15 +118,15 @@
118 118 global $wpdb;
119 119 $table_name = uwp_get_table_prefix() . 'uwp_form_fields';
120 120 $enable_old_password = uwp_get_option( 'change_enable_old_password', false );
121 121 $user_id = get_current_user_id();
122 - if ( $user_id && 1 == get_user_meta( $user_id, 'is_uwp_social_login_no_password', true ) ) {
122 + if($user_id && 1 == get_user_meta($user_id, 'is_uwp_social_login_no_password', true)){
123 123 $enable_old_password = 0;
124 124 }
125 125 if ( $enable_old_password == '1' ) {
126 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) );
126 + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' ORDER BY sort_order ASC", array( 'change' ) ) );
127 127 } else {
128 - $fields = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) );
128 + $fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE form_type = %s AND is_active = '1' AND for_admin_use != '1' AND htmlvar_name != 'old_password' ORDER BY sort_order ASC", array( 'change' ) ) );
129 129 }
130 130
131 131 return $fields;
132 132 }
@@ -183,12 +183,14 @@
183 183 $placeholder = __( $field->placeholder_value, 'userswp' );
184 184 } else {
185 185 $placeholder = wp_sprintf( __( 'Choose %s…', 'userswp' ), uwp_get_form_label( $field ) );
186 186 }
187 - } elseif ( isset( $field->placeholder_value ) && ! empty( $field->placeholder_value ) ) {
187 + } else {
188 + if ( isset( $field->placeholder_value ) && ! empty( $field->placeholder_value ) ) {
188 189 $placeholder = __( $field->placeholder_value, 'userswp' );
189 190 } else {
190 - $placeholder = uwp_get_form_label( $field );
191 + $placeholder = uwp_get_form_label( $field );
192 + }
191 193 }
192 194
193 195 if ( isset( $field->is_required ) && ! empty( $field->is_required ) ) {
194 196 $placeholder .= ' *';
@@ -237,28 +239,23 @@
237 239 return $custom_field_info[ $cache_key ];
238 240 }
239 241
240 242 if ( $form_type ) {
241 - $field = $wpdb->get_row(
242 - $wpdb->prepare(
243 - 'SELECT * FROM ' . $table_name . ' WHERE htmlvar_name = %s AND form_type = %s',
244 - array(
245 - $htmlvar_name,
246 - $form_type,
247 - )
248 - )
249 - );
243 + $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE htmlvar_name = %s AND form_type = %s", array(
244 + $htmlvar_name,
245 + $form_type
246 + ) ) );
250 247 } else {
251 - $field = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $table_name . ' WHERE htmlvar_name = %s', array( $htmlvar_name ) ) );
248 + $field = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE htmlvar_name = %s", array( $htmlvar_name ) ) );
252 249 }
253 -
250 +
254 251 // Cache the field data.
255 252 $custom_field_info[ $cache_key ] = $field;
256 -
253 +
257 254 return $field;
258 255 }
259 256
260 -function uwp_resend_activation_mail( $user_id ) {
257 +function uwp_resend_activation_mail($user_id) {
261 258
262 259 if ( ! $user_id ) {
263 260 return false;
264 261 }
@@ -271,9 +268,9 @@
271 268 if ( $activation_link ) {
272 269
273 270 $message = __( 'To activate your account, visit the following address:', 'userswp' ) . "\r\n\r\n";
274 271
275 - $message .= "<a href='" . esc_url( $activation_link ) . "' target='_blank'>" . esc_url( $activation_link ) . '</a>' . "\r\n";
272 + $message .= "<a href='" . esc_url( $activation_link ) . "' target='_blank'>" . esc_url( $activation_link ) . "</a>" . "\r\n";
276 273
277 274 $activate_message = '<p><b>' . __( 'Please activate your account :', 'userswp' ) . '</b></p><p>' . $message . '</p>';
278 275
279 276 $activate_message = apply_filters( 'uwp_activation_mail_message', $activate_message, $user_id );
@@ -306,9 +303,9 @@
306 303 if ( strpos( $fa_icon, 'fa fa-' ) === 0 || strpos( $fa_icon, 'fas fa-' ) === 0 || strpos( $fa_icon, 'far fa-' ) === 0 || strpos( $fa_icon, 'fab fa-' ) === 0 || strpos( $fa_icon, 'fa-' ) === 0 ) {
307 304 $return = true;
308 305 }
309 306 }
310 - return apply_filters( 'uwp_is_fa_icon', $return, $icon );
307 + return apply_filters( 'uwp_is_fa_icon', $return, $icon );
311 308 }
312 309
313 310 /**
314 311 * Check icon url.
@@ -323,9 +320,9 @@
323 320 if ( strpos( $icon, 'http://' ) === 0 || strpos( $icon, 'https://' ) === 0 ) {
324 321 $return = true;
325 322 }
326 323 }
327 - return apply_filters( 'uwp_is_icon_url', $return, $icon );
324 + return apply_filters( 'uwp_is_icon_url', $return, $icon );
328 325 }
329 326
330 327 /**
331 328 * Get the field icon.
@@ -339,9 +336,9 @@
339 336 function uwp_get_field_icon( $value ) {
340 337 $field_icon = $value;
341 338
342 339 if ( ! empty( $value ) ) {
343 - if ( strpos( $value, 'http' ) === 0 ) {
340 + if (strpos($value, 'http') === 0) {
344 341 $field_icon = '<span class="uwp_field_icon" style="background: url(' . esc_url( $value ) . ') no-repeat left center;padding-left:14px;background-size:100% auto;margin-right:5px"></span>';
345 342 } else {
346 343 $field_icon = '<i class="uwp_field_icon ' . esc_attr( $value ) . '"></i>';
347 344 }
@@ -349,19 +346,19 @@
349 346
350 347 return apply_filters( 'uwp_get_field_icon', $field_icon, $value );
351 348 }
352 349
353 -function uwp_get_registration_form_actions() {
350 +function uwp_get_registration_form_actions(){
354 351 $registration_options = array(
355 - 'auto_approve' => __( 'Auto Approve', 'userswp' ),
356 - 'auto_approve_login' => __( 'Auto Approve + Auto Login', 'userswp' ),
357 - 'require_email_activation' => __( 'Require Email Activation', 'userswp' ),
352 + 'auto_approve' => __('Auto Approve', 'userswp'),
353 + 'auto_approve_login' => __('Auto Approve + Auto Login', 'userswp'),
354 + 'require_email_activation' => __('Require Email Activation', 'userswp'),
358 355 );
359 356
360 - return apply_filters( 'uwp_registration_status_options', $registration_options );
357 + return apply_filters('uwp_registration_status_options', $registration_options);
361 358 }
362 359
363 -function uwp_get_register_forms_dropdown_options( $include_forms = array() ) {
360 +function uwp_get_register_forms_dropdown_options($include_forms = array()) {
364 361
365 362 $get_register_form = uwp_get_option( 'multiple_registration_forms' );
366 363
367 364 $register_forms = array();
@@ -374,12 +371,12 @@
374 371 }
375 372 }
376 373 }
377 374
378 - if ( ! empty( $register_forms ) && isset( $include_forms ) && count( $include_forms ) > 0 ) {
379 - foreach ( $register_forms as $form_id => $title ) {
380 - if ( ! in_array( $form_id, $include_forms ) ) {
381 - unset( $register_forms[ $form_id ] );
375 + if(!empty($register_forms) && isset($include_forms) && count($include_forms) > 0){
376 + foreach($register_forms as $form_id => $title){
377 + if(!in_array($form_id, $include_forms)){
378 + unset($register_forms[$form_id]);
382 379 }
383 380 }
384 381 }
385 382
@@ -397,9 +394,9 @@
397 394 foreach ( $get_register_form as $key => $register_form ) {
398 395
399 396 if ( ! empty( $register_form['id'] ) && $register_form['id'] == $form_id ) {
400 397
401 - $form_title = ! empty( $register_form[ $type ] ) ? $register_form[ $type ] : '';
398 + $form_title = ! empty( $register_form[$type] ) ? $register_form[$type] : '';
402 399 }
403 400 }
404 401 }
405 402 }
@@ -406,11 +403,11 @@
406 403
407 404 return $form_title;
408 405 }
409 406
410 -function uwp_get_form_id_by_type( $form_type ) {
407 +function uwp_get_form_id_by_type($form_type){
411 408 $form_id = 1;
412 - if ( isset( $form_type ) && ! empty( $form_type ) ) {
409 + if ( isset($form_type) && ! empty( $form_type ) ) {
413 410 $get_register_form = uwp_get_option( 'multiple_registration_forms' );
414 411
415 412 if ( ! empty( $get_register_form ) && is_array( $get_register_form ) ) {
416 413
@@ -415,9 +412,9 @@
415 412 if ( ! empty( $get_register_form ) && is_array( $get_register_form ) ) {
416 413
417 414 foreach ( $get_register_form as $key => $register_form ) {
418 415
419 - if ( ! empty( $register_form['title'] ) && $form_type == sanitize_title_with_dashes( $register_form['title'] ) ) {
416 + if ( ! empty( $register_form['title'] ) && $form_type == sanitize_title_with_dashes($register_form['title']) ) {
420 417
421 418 $form_id = $register_form['id'];
422 419 }
423 420 }
@@ -463,26 +460,8 @@
463 460
464 461 return ! empty( $form_id ) ? (int) $form_id : 1;
465 462 }
466 463
467 -/**
468 - * Get user regsitration form by form ID.
469 - *
470 - * @param int $form_id The ID of the registration form.
471 - * @return array|false The user type array if found, false otherwise.
472 - */
473 -function uwp_get_user_register_form( int $form_id ) {
474 - $register_forms = (array) UsersWP_User_Types::get_register_forms();
475 -
476 - foreach ( $register_forms as $register_form ) {
477 - if ( isset( $register_form['id'] ) && (int) $register_form['id'] === (int) $form_id ) {
478 - return $register_form;
479 - }
480 - }
481 -
482 - return false;
483 -}
484 -
485 464 function uwp_get_register_fields_htmlvar( $form_id = 1 ) {
486 465
487 466 $fields = get_register_form_fields( $form_id );
488 467
@@ -501,10 +480,10 @@
501 480
502 481 return $html_var;
503 482 }
504 483
505 -function uwp_get_unique_custom_fields( $fields, $key = 'htmlvar_name' ) {
506 - if ( empty( $fields ) ) {
484 +function uwp_get_unique_custom_fields($fields, $key = 'htmlvar_name'){
485 + if(empty($fields)){
507 486 return array();
508 487 }
509 488
510 489 $temp_array = array();
@@ -510,34 +489,34 @@
510 489 $temp_array = array();
511 490 $i = 0;
512 491 $key_array = array();
513 492
514 - foreach ( $fields as $field ) {
515 - if ( is_object( $field ) ) {
493 + foreach($fields as $field) {
494 + if(is_object($field)){
516 495 $val = $field->$key;
517 496 } else {
518 - $val = $field[ $key ];
497 + $val = $field[$key];
519 498 }
520 499
521 - if ( ! in_array( $val, $key_array ) ) {
522 - $key_array[ $i ] = $val;
523 - $temp_array[ $val ] = $field;
500 + if (!in_array($val, $key_array)) {
501 + $key_array[$i] = $val;
502 + $temp_array[$val] = $field;
524 503 }
525 - ++$i;
504 + $i++;
526 505 }
527 506
528 507 return $temp_array;
529 508 }
530 509
531 -function uwp_get_default_form_data() {
510 +function uwp_get_default_form_data(){
532 511 $fields = array();$i = 1;
533 - $user_role = get_option( 'default_role' );
512 + $user_role = get_option('default_role');
534 513
535 514 $account_fields = UsersWP_Activator::uwp_default_custom_fields_account();
536 - if ( ! empty( $account_fields ) ) {
537 - foreach ( $account_fields as $account_field ) {
538 - $fields[ $account_field['htmlvar_name'] ] = $i;
539 - ++$i;
515 + if(!empty($account_fields)){
516 + foreach ($account_fields as $account_field){
517 + $fields[$account_field['htmlvar_name']] = $i;
518 + $i++;
540 519 }
541 520 }
542 521
543 522 $reg_fields = get_register_form_fields();
@@ -553,41 +532,41 @@
553 532 }
554 533
555 534 $data = array(
556 535 array(
557 - 'id' => 1,
558 - 'title' => __( 'Default', 'userswp' ),
559 - 'user_role' => $user_role,
560 - 'reg_action' => uwp_get_option( 'uwp_registration_action', 'auto_approve' ),
536 + 'id' => 1,
537 + 'title' => __('Default','userswp'),
538 + 'user_role' => $user_role,
539 + 'reg_action' => uwp_get_option( 'uwp_registration_action', 'auto_approve' ),
561 540 'redirect_to' => (int) uwp_get_option( 'register_redirect_to', - 1 ),
562 - 'custom_url' => uwp_get_option( 'register_redirect_custom_url', home_url() ),
563 - 'gdpr_page' => (int) uwp_get_option( 'register_gdpr_page', false ),
564 - 'tos_page' => (int) uwp_get_option( 'register_terms_page', false ),
565 - 'fields' => $fields,
566 - ),
541 + 'custom_url' => uwp_get_option( 'register_redirect_custom_url', home_url() ),
542 + 'gdpr_page' => (int) uwp_get_option('register_gdpr_page', false),
543 + 'tos_page' => (int) uwp_get_option('register_terms_page', false),
544 + 'fields' => $fields
545 + )
567 546 );
568 547
569 548 return $data;
570 549 }
571 550
572 -function uwp_get_upload_image_size( $type = 'avatar' ) {
551 +function uwp_get_upload_image_size($type = "avatar"){
573 552
574 553 if ( $type == 'avatar' ) {
575 554 $width = uwp_get_option( 'profile_avatar_width', 150 );
576 - $width = empty( $width ) ? 150 : $width;
555 + $width = empty($width) ? 150 : $width;
577 556 $value['width'] = apply_filters( 'uwp_avatar_image_width', $width );
578 557
579 558 $height = uwp_get_option( 'profile_avatar_height', 150 );
580 - $height = empty( $height ) ? 150 : $height;
559 + $height = empty($height) ? 150 : $height;
581 560 $value['height'] = apply_filters( 'uwp_avatar_image_height', $height );
582 561 } else {
583 562 $width = uwp_get_option( 'profile_banner_width', 1000 );
584 - $width = empty( $width ) ? 1000 : $width;
563 + $width = empty($width) ? 1000 : $width;
585 564 $value['width'] = apply_filters( 'uwp_banner_image_width', $width );
586 565
587 566 $height = uwp_get_option( 'profile_banner_height', 300 );
588 - $height = empty( $height ) ? 300 : $height;
567 + $height = empty($height) ? 300 : $height;
589 568 $value['height'] = apply_filters( 'uwp_banner_image_height', $height );
590 569 }
591 570
592 571 return $value;
593 -}
572 +}