Cimy User Extra Fields - Version 2.4.0

Version Description

Download this release

Release Info

Developer Cimmo
Plugin Icon wp plugin Cimy User Extra Fields
Version 2.4.0
Comparing to
See all releases

Code changes from version 2.3.11 to 2.4.0

README_OFFICIAL.txt CHANGED
@@ -423,11 +423,11 @@ if (count($allFields) > 0) {
423
  foreach ($allFields as $field) {
424
  echo "ID: ".$field['ID']." \n";
425
  echo "F_ORDER: ".$field['F_ORDER']." \n";
426
- echo "NAME: ".$field['NAME']." \n";
427
- echo "TYPE: ".$field['TYPE']." \n";
428
- echo "VALUE: ".$field['VALUE']." \n";
429
- echo "LABEL: ".$field['LABEL']." \n";
430
- echo "DESCRIPTION: ".$field['DESCRIPTION']." \n";
431
 
432
  echo "RULES: ";
433
  print_r($field['RULES']);
@@ -474,6 +474,13 @@ crop_x1=0,crop_y1=0,crop_x2=80,crop_y2=90 - pre-select cropping window
474
  filename=default.pdf - rename the uploaded file to the given file name
475
 
476
 
 
 
 
 
 
 
 
477
  KNOWN ISSUES:
478
  - if you add too many fields in the "Users Extended" menu they will go out of frame
479
  - some rules are never applied if you are using PHP 4.x please update to PHP 5.x as stated in the REQUIREMENTS
@@ -619,6 +626,14 @@ A lot of times I cannot reproduce the problem and I need more details, so if you
619
 
620
 
621
  CHANGELOG:
 
 
 
 
 
 
 
 
622
  v2.3.11 - 29/10/2012
623
  - Fixed reCAPTCHA was not working on secure webservers (thanks to invisnet for the patch)
624
  - Fixed extra lines outputted by php files (thanks to Ov3rfly)
423
  foreach ($allFields as $field) {
424
  echo "ID: ".$field['ID']." \n";
425
  echo "F_ORDER: ".$field['F_ORDER']." \n";
426
+ echo "NAME: ".cimy_uef_sanitize_content($field['NAME'])." \n";
427
+ echo "TYPE: ".cimy_uef_sanitize_content($field['TYPE'])." \n";
428
+ echo "VALUE: ".cimy_uef_sanitize_content($field['VALUE'])." \n";
429
+ echo "LABEL: ".cimy_uef_sanitize_content($field['LABEL'])." \n";
430
+ echo "DESCRIPTION: ".cimy_uef_sanitize_content($field['DESCRIPTION'])." \n";
431
 
432
  echo "RULES: ";
433
  print_r($field['RULES']);
474
  filename=default.pdf - rename the uploaded file to the given file name
475
 
476
 
477
+ HOW TO USE WPML SUPPORT:
478
+ Since v2.4.0 field's label and description can be translated using the WordPress Multilingual plug-in.
479
+ To use it in your code you can get the get_cimyFields example above and change only the following lines:
480
+ echo "LABEL: ".cimy_uef_sanitize_content(cimy_wpml_translate_string($field['LABEL']))." \n";
481
+ echo "DESCRIPTION: ".cimy_uef_sanitize_content(cimy_wpml_translate_string($field['DESCRIPTION']))." \n";
482
+
483
+
484
  KNOWN ISSUES:
485
  - if you add too many fields in the "Users Extended" menu they will go out of frame
486
  - some rules are never applied if you are using PHP 4.x please update to PHP 5.x as stated in the REQUIREMENTS
626
 
627
 
628
  CHANGELOG:
629
+ v2.4.0 - 27/12/2012
630
+ - Added support for the WordPress Multilingual plug-in.
631
+ - Fixed plain text password was staying in the DataBase for registered users (WordPress MS and WordPress + confirmation email only)
632
+ - Fixed (better) background logo was stretched under Safari (thanks to DarioDN)
633
+ - Fixed PHP warnings wpdb::supports_collation usage on WordPress 3.5
634
+ - Fixed PHP warnings wpdb::prepare usage on WordPress 3.5
635
+ - Fixed PHP warnings on Extended Users page on WordPress 3.5
636
+
637
  v2.3.11 - 29/10/2012
638
  - Fixed reCAPTCHA was not working on secure webservers (thanks to invisnet for the patch)
639
  - Fixed extra lines outputted by php files (thanks to Ov3rfly)
cimy_uef_admin.php CHANGED
@@ -176,6 +176,10 @@ function cimy_admin_define_extra_fields() {
176
  $sql_data_del.= "FIELD_ID=".$i;
177
  $sql.= "F_ORDER=".$i;
178
  $msg.= $i;
 
 
 
 
179
  }
180
  else // field to NOT be deleted, but order probably have to change, if j==(-1) then order is ok because deletions is after it!
181
  if ($j > (-1)) {
@@ -401,8 +405,17 @@ function cimy_admin_define_extra_fields() {
401
 
402
  if ($action == "add")
403
  $results['inserted'] = __("Field inserted correctly", $cimy_uef_domain);
404
- else if ($action == "edit")
405
  $results['edit'] = __("Field #", $cimy_uef_domain).$field_order." ".__("updated correctly", $cimy_uef_domain);
 
 
 
 
 
 
 
 
 
406
  }
407
  else {
408
  $errors['namedup'] = __("Name inserted is just in the database, change to another one", $cimy_uef_domain);
@@ -446,6 +459,8 @@ function cimy_admin_define_extra_fields() {
446
  $type = "text";
447
 
448
  $selected_input["name"] = '';
 
 
449
  $selected_input["desc"] = '';
450
  $selected_input["min_length"] = '';
451
  $selected_input["exact_length"] = '';
@@ -499,9 +514,6 @@ function cimy_admin_define_extra_fields() {
499
  if (isset($store_rule['advanced_options']))
500
  $selected_input["advanced_options"] = $store_rule['advanced_options'];
501
  }
502
- // action is not "add"
503
- else {
504
- }
505
 
506
  // CAN BE EMPTY
507
  if ((!isset($store_rule['can_be_empty'])) || ($store_rule['can_be_empty'] == true) || ($action != "add"))
@@ -1166,7 +1178,7 @@ function cimy_admin_users_list_page() {
1166
  'per_page' => $users_per_page,
1167
  ));
1168
  }
1169
- function bulk_actions($which) {}
1170
  function extra_tablenav($which) {
1171
  if ('top' != $which)
1172
  return;
@@ -1249,7 +1261,7 @@ function cimy_admin_users_list_page() {
1249
  'per_page' => $users_per_page,
1250
  ));
1251
  }
1252
- function bulk_actions($which) {}
1253
  function extra_tablenav($which) {
1254
  if ('top' != $which)
1255
  return;
176
  $sql_data_del.= "FIELD_ID=".$i;
177
  $sql.= "F_ORDER=".$i;
178
  $msg.= $i;
179
+ // wpml stuff, unregister label and description for deleted fields
180
+ $field_to_del_name = substr(stripslashes($_POST['name'][$i]), 0, $max_length_name);
181
+ cimy_wpml_unregister_string($field_to_del_name."_label");
182
+ cimy_wpml_unregister_string($field_to_del_name."_desc");
183
  }
184
  else // field to NOT be deleted, but order probably have to change, if j==(-1) then order is ok because deletions is after it!
185
  if ($j > (-1)) {
405
 
406
  if ($action == "add")
407
  $results['inserted'] = __("Field inserted correctly", $cimy_uef_domain);
408
+ else if ($action == "edit") {
409
  $results['edit'] = __("Field #", $cimy_uef_domain).$field_order." ".__("updated correctly", $cimy_uef_domain);
410
+ // wpml stuff, unregister the string if name changed
411
+ if ($name != $oldname && !empty($oldname)) {
412
+ cimy_wpml_unregister_string($oldname."_label");
413
+ cimy_wpml_unregister_string($oldname."_desc");
414
+ }
415
+ }
416
+ // wpml stuff, always register or update
417
+ cimy_wpml_register_string($name."_label", $label);
418
+ cimy_wpml_register_string($name."_desc", $desc);
419
  }
420
  else {
421
  $errors['namedup'] = __("Name inserted is just in the database, change to another one", $cimy_uef_domain);
459
  $type = "text";
460
 
461
  $selected_input["name"] = '';
462
+ $selected_input["label"] = '';
463
+ $selected_input["value"] = '';
464
  $selected_input["desc"] = '';
465
  $selected_input["min_length"] = '';
466
  $selected_input["exact_length"] = '';
514
  if (isset($store_rule['advanced_options']))
515
  $selected_input["advanced_options"] = $store_rule['advanced_options'];
516
  }
 
 
 
517
 
518
  // CAN BE EMPTY
519
  if ((!isset($store_rule['can_be_empty'])) || ($store_rule['can_be_empty'] == true) || ($action != "add"))
1178
  'per_page' => $users_per_page,
1179
  ));
1180
  }
1181
+ function bulk_actions() {}
1182
  function extra_tablenav($which) {
1183
  if ('top' != $which)
1184
  return;
1261
  'per_page' => $users_per_page,
1262
  ));
1263
  }
1264
+ function bulk_actions() {}
1265
  function extra_tablenav($which) {
1266
  if ('top' != $which)
1267
  return;
cimy_uef_db.php CHANGED
@@ -18,7 +18,7 @@ function cimy_plugin_install () {
18
 
19
  $charset_collate = "";
20
  // try to get proper charset and collate
21
- if ( $wpdb->supports_collation() ) {
22
  if ( ! empty($wpdb->charset) )
23
  $charset_collate = " DEFAULT CHARACTER SET $wpdb->charset";
24
  if ( ! empty($wpdb->collate) )
@@ -259,6 +259,25 @@ function cimy_plugin_install () {
259
  $options['tinymce_fields'] = $javascripts_dep['tinymce_fields'];
260
  }
261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  $options['version'] = $cimy_uef_version;
263
 
264
  cimy_set_options($options);
@@ -292,7 +311,7 @@ function cimy_force_signup_table_creation() {
292
  $charset_collate = "";
293
 
294
  // try to get proper charset and collate
295
- if ( $wpdb->supports_collation() ) {
296
  if ( ! empty($wpdb->charset) )
297
  $charset_collate = " DEFAULT CHARACTER SET $wpdb->charset";
298
  if ( ! empty($wpdb->collate) )
18
 
19
  $charset_collate = "";
20
  // try to get proper charset and collate
21
+ if ($wpdb->has_cap('collation')) {
22
  if ( ! empty($wpdb->charset) )
23
  $charset_collate = " DEFAULT CHARACTER SET $wpdb->charset";
24
  if ( ! empty($wpdb->collate) )
259
  $options['tinymce_fields'] = $javascripts_dep['tinymce_fields'];
260
  }
261
 
262
+ if (version_compare($options['version'], "2.3.11", "<=") === true) {
263
+ for ($i = 0; $i <= 1; $i++) {
264
+ if ($i == 0)
265
+ $the_table = $wpdb_wp_fields_table;
266
+ else
267
+ $the_table = $wpdb_fields_table;
268
+
269
+ $sql = "SELECT ID, RULES FROM ".$the_table;
270
+ $all_fields = $wpdb->get_results($sql, ARRAY_A);
271
+
272
+ if (!empty($all_fields)) {
273
+ foreach ($all_fields as $field) {
274
+ cimy_wpml_register_string($field['NAME']."_label", $field['LABEL']);
275
+ cimy_wpml_register_string($field['NAME']."_desc", $field['DESCRIPTION']);
276
+ }
277
+ }
278
+ }
279
+ }
280
+
281
  $options['version'] = $cimy_uef_version;
282
 
283
  cimy_set_options($options);
311
  $charset_collate = "";
312
 
313
  // try to get proper charset and collate
314
+ if ($wpdb->has_cap('collation')) {
315
  if ( ! empty($wpdb->charset) )
316
  $charset_collate = " DEFAULT CHARACTER SET $wpdb->charset";
317
  if ( ! empty($wpdb->collate) )
cimy_uef_functions.php CHANGED
@@ -15,7 +15,7 @@ function get_cimyFields($wp_fields=false, $order_by_section=false) {
15
  $order = " ORDER BY F_ORDER";
16
 
17
  // if tables exist then read all fields else array empty, will be read after the creation
18
- if($wpdb->get_var("SHOW TABLES LIKE '".$table."'") == $table) {
19
  $sql = "SELECT * FROM ".$table.$order;
20
  $extra_fields = $wpdb->get_results($sql, ARRAY_A);
21
 
@@ -912,3 +912,23 @@ function cimy_uef_get_allowed_image_extensions() {
912
  $image_ext = array_merge($image_ext, explode('|', $key));
913
  return $image_ext;
914
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  $order = " ORDER BY F_ORDER";
16
 
17
  // if tables exist then read all fields else array empty, will be read after the creation
18
+ if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") == $table) {
19
  $sql = "SELECT * FROM ".$table.$order;
20
  $extra_fields = $wpdb->get_results($sql, ARRAY_A);
21
 
912
  $image_ext = array_merge($image_ext, explode('|', $key));
913
  return $image_ext;
914
  }
915
+
916
+ // http://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/
917
+ function cimy_wpml_register_string($name, $value) {
918
+ global $cimy_uef_name;
919
+ if (function_exists('icl_register_string'))
920
+ icl_register_string($cimy_uef_name, $name, $value);
921
+ }
922
+
923
+ function cimy_wpml_translate_string($name, $value) {
924
+ global $cimy_uef_name;
925
+ if (function_exists('icl_t'))
926
+ return icl_t($cimy_uef_name, $name, $value);
927
+ return $value;
928
+ }
929
+
930
+ function cimy_wpml_unregister_string($name) {
931
+ global $cimy_uef_name;
932
+ if (function_exists('icl_unregister_string'))
933
+ icl_unregister_string($cimy_uef_name, $name);
934
+ }
cimy_uef_profile.php CHANGED
@@ -69,8 +69,8 @@ function cimy_extract_ExtraFields() {
69
  $name = $thisField['NAME'];
70
  $rules = $thisField['RULES'];
71
  $type = $thisField['TYPE'];
72
- $label = $thisField['LABEL'];
73
- $description = cimy_uef_sanitize_content($thisField['DESCRIPTION']);
74
  $fieldset = $thisField['FIELDSET'];
75
  $unique_id = $fields_name_prefix.$field_id;
76
  $input_name = $fields_name_prefix.esc_attr($name);
@@ -98,11 +98,11 @@ function cimy_extract_ExtraFields() {
98
  // if ($d_field['FIELD_ID'] == $field_id)
99
  // $value = $d_field['VALUE'];
100
  // }
101
- $value = $wpdb->get_var($wpdb->prepare("SELECT VALUE FROM ".$wpdb_data_table." WHERE USER_ID=".$get_user_id." AND FIELD_ID=".$field_id));
102
  $old_value = $value;
103
 
104
  if (($type == "radio") && (empty($radio_checked[$name])))
105
- $radio_checked[$name] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".$wpdb_data_table." WHERE USER_ID=".$get_user_id." AND FIELD_ID=".$field_id." AND VALUE=\"selected\""));
106
 
107
  // if nothing is inserted and field admin default value then assign it
108
  if (in_array($type, $rule_profile_value)) {
69
  $name = $thisField['NAME'];
70
  $rules = $thisField['RULES'];
71
  $type = $thisField['TYPE'];
72
+ $label = cimy_wpml_translate_string($name."_label", $thisField["LABEL"]);
73
+ $description = cimy_uef_sanitize_content(cimy_wpml_translate_string($name."_desc", $thisField["DESCRIPTION"]));
74
  $fieldset = $thisField['FIELDSET'];
75
  $unique_id = $fields_name_prefix.$field_id;
76
  $input_name = $fields_name_prefix.esc_attr($name);
98
  // if ($d_field['FIELD_ID'] == $field_id)
99
  // $value = $d_field['VALUE'];
100
  // }
101
+ $value = $wpdb->get_var($wpdb->prepare("SELECT VALUE FROM ".$wpdb_data_table." WHERE USER_ID=%d AND FIELD_ID=%d", $get_user_id, $field_id));
102
  $old_value = $value;
103
 
104
  if (($type == "radio") && (empty($radio_checked[$name])))
105
+ $radio_checked[$name] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".$wpdb_data_table." WHERE USER_ID=%d AND FIELD_ID=%d AND VALUE=\"selected\"", $get_user_id, $field_id));
106
 
107
  // if nothing is inserted and field admin default value then assign it
108
  if (in_array($type, $rule_profile_value)) {
cimy_uef_register.php CHANGED
@@ -113,6 +113,18 @@ function cimy_register_user_extra_fields($user_id, $password="", $meta=array())
113
  if (!empty($signup))
114
  return;
115
  }
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
  $i = 1;
118
 
@@ -254,7 +266,7 @@ function cimy_register_user_extra_fields($user_id, $password="", $meta=array())
254
  }
255
 
256
  if ($user_signups) {
257
- $sql = $wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID=$user_id");
258
  $saved_user = array_shift($wpdb->get_results($sql));
259
  $key = substr( md5( time() . rand() . $saved_user->user_email ), 0, 16 );
260
 
@@ -266,10 +278,10 @@ function cimy_register_user_extra_fields($user_id, $password="", $meta=array())
266
  'activation_key' => $key,
267
  'meta' => serialize($meta),
268
  ));
269
- $sql = $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID=$user_id");
270
  $wpdb->query($sql);
271
 
272
- $sql = $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id=$user_id");
273
  $wpdb->query($sql);
274
 
275
  cimy_signup_user_notification($saved_user->user_login, $saved_user->user_email, $key, serialize($meta));
@@ -717,8 +729,8 @@ function cimy_registration_form($errors=null, $show_type=0) {
717
  $rules = $thisField['RULES'];
718
  $type = $thisField['TYPE'];
719
  $old_type = $type;
720
- $label = $thisField['LABEL'];
721
- $description = cimy_uef_sanitize_content($thisField['DESCRIPTION']);
722
  $fieldset = empty($thisField['FIELDSET']) ? 0 : $thisField['FIELDSET'];
723
  $maxlen = 0;
724
  $unique_id = $prefix.$field_id;
@@ -1294,7 +1306,7 @@ function cimy_change_login_registration_logo() {
1294
  #login h1:first-child a:first-child {
1295
  background: url(<?php echo esc_url($cuef_upload_webpath.basename($options["registration-logo"])); ?>) no-repeat top center;
1296
  background-position: center top;
1297
- background-size: auto auto;
1298
  width: <?php echo max(328, $logo_width); ?>px;
1299
  height: <?php echo $logo_height; ?>px;
1300
  text-indent: -9999px;
113
  if (!empty($signup))
114
  return;
115
  }
116
+ if (!empty($meta)) {
117
+ $user = new WP_User((int) $user_id);
118
+ $meta_db = $wpdb->get_var($wpdb->prepare("SELECT meta FROM ".$wpdb->prefix."signups WHERE user_login = %s", $user->user_login));
119
+ $meta_db = unserialize($meta_db);
120
+ // password detected, kill it!
121
+ if (!empty($meta_db['cimy_uef_wp_PASSWORD'])) {
122
+ unset($meta_db['cimy_uef_wp_PASSWORD']);
123
+ if (!empty($meta_db['cimy_uef_wp_PASSWORD2']))
124
+ unset($meta_db['cimy_uef_wp_PASSWORD2']);
125
+ $wpdb->update($wpdb->prefix."signups", array('meta' => serialize($meta_db)), array('user_login' => $user->user_login));
126
+ }
127
+ }
128
 
129
  $i = 1;
130
 
266
  }
267
 
268
  if ($user_signups) {
269
+ $sql = $wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID=%d", $user_id);
270
  $saved_user = array_shift($wpdb->get_results($sql));
271
  $key = substr( md5( time() . rand() . $saved_user->user_email ), 0, 16 );
272
 
278
  'activation_key' => $key,
279
  'meta' => serialize($meta),
280
  ));
281
+ $sql = $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID=%d", $user_id);
282
  $wpdb->query($sql);
283
 
284
+ $sql = $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id=%d", $user_id);
285
  $wpdb->query($sql);
286
 
287
  cimy_signup_user_notification($saved_user->user_login, $saved_user->user_email, $key, serialize($meta));
729
  $rules = $thisField['RULES'];
730
  $type = $thisField['TYPE'];
731
  $old_type = $type;
732
+ $label = cimy_wpml_translate_string($name."_label", $thisField["LABEL"]);
733
+ $description = cimy_uef_sanitize_content(cimy_wpml_translate_string($name."_desc", $thisField["DESCRIPTION"]));
734
  $fieldset = empty($thisField['FIELDSET']) ? 0 : $thisField['FIELDSET'];
735
  $maxlen = 0;
736
  $unique_id = $prefix.$field_id;
1306
  #login h1:first-child a:first-child {
1307
  background: url(<?php echo esc_url($cuef_upload_webpath.basename($options["registration-logo"])); ?>) no-repeat top center;
1308
  background-position: center top;
1309
+ background-size: <?php echo $logo_width; ?>px <?php echo $logo_height; ?>px;
1310
  width: <?php echo max(328, $logo_width); ?>px;
1311
  height: <?php echo $logo_height; ?>px;
1312
  text-indent: -9999px;
cimy_user_extra_fields.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cimy User Extra Fields
4
  Plugin URI: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/
5
  Description: Add some useful fields to registration and user's info
6
- Version: 2.3.11
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
@@ -162,7 +162,7 @@ require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
162
  add_action('admin_init', 'cimy_uef_admin_init');
163
 
164
  $cimy_uef_name = "Cimy User Extra Fields";
165
- $cimy_uef_version = "2.3.11";
166
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
167
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
168
 
3
  Plugin Name: Cimy User Extra Fields
4
  Plugin URI: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/
5
  Description: Add some useful fields to registration and user's info
6
+ Version: 2.4.0
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
162
  add_action('admin_init', 'cimy_uef_admin_init');
163
 
164
  $cimy_uef_name = "Cimy User Extra Fields";
165
+ $cimy_uef_version = "2.4.0";
166
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
167
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
168
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Website link: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra
5
  Tags: cimy, admin, registration, profile, extra fields, avatar, gravatar, recaptcha, captcha
6
  Requires at least: 3.1
7
  Tested up to: 3.5
8
- Stable tag: 2.3.11
9
 
10
  Add some useful fields to registration and user's info
11
 
5
  Tags: cimy, admin, registration, profile, extra fields, avatar, gravatar, recaptcha, captcha
6
  Requires at least: 3.1
7
  Tested up to: 3.5
8
+ Stable tag: 2.4.0
9
 
10
  Add some useful fields to registration and user's info
11