Cimy User Extra Fields - Version 2.4.2

Version Description

Download this release

Release Info

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

Code changes from version 2.4.1 to 2.4.2

README_OFFICIAL.txt CHANGED
@@ -626,6 +626,11 @@ A lot of times I cannot reproduce the problem and I need more details, so if you
626
 
627
 
628
  CHANGELOG:
 
 
 
 
 
629
  v2.4.1 - 11/02/2013
630
  - Added support for welcome email, extra fields title and fieldset titles under the WordPress Multilingual plug-in (thanks to Piet for testing it)
631
  - Added Arabic translation (Mamoun Elkheir)
626
 
627
 
628
  CHANGELOG:
629
+ v2.4.2 - 18/02/2013
630
+ - Fixed missing 'cimy_update_ExtraFields' PHP warning (introduced in v2.4.1) (thanks to Ashton Clark and vtxyzzy)
631
+ - Fixed WordPress MS per-blog installation was not working for non main sites since WordPress MS 3.5 (thanks to Denis Lam)
632
+ - Fixed WordPress MS per-blog installation was not deleting cimy tables when blog is deleted
633
+
634
  v2.4.1 - 11/02/2013
635
  - Added support for welcome email, extra fields title and fieldset titles under the WordPress Multilingual plug-in (thanks to Piet for testing it)
636
  - Added Arabic translation (Mamoun Elkheir)
cimy_uef_db.php CHANGED
@@ -509,7 +509,7 @@ if (!function_exists("cimy_rfr")) {
509
  }
510
 
511
  function cimy_delete_blog_info($blog_id, $drop) {
512
- global $cuef_upload_path;
513
 
514
  $file_path = $cuef_upload_path.$blog_id."/";
515
 
@@ -519,6 +519,16 @@ function cimy_delete_blog_info($blog_id, $drop) {
519
  // delete also the subdir
520
  if (is_dir($file_path))
521
  rmdir($file_path);
 
 
 
 
 
 
 
 
 
 
522
  }
523
 
524
  function cimy_delete_users_info($fields_id) {
@@ -594,5 +604,5 @@ function cimy_uef_get_meta_from_user_login($user_login) {
594
  function cimy_uef_get_meta_from_url($domain, $path) {
595
  global $wpdb;
596
 
597
- return $wpdb->get_row($wpdb->prepare("SELECT user_login, user_email, meta FROM ".$wpdb->prefix."signups WHERE domain = %s AND path = %s AND active = %d", $domain, $path, 0), ARRAY_A );
598
  }
509
  }
510
 
511
  function cimy_delete_blog_info($blog_id, $drop) {
512
+ global $cuef_upload_path, $cimy_uef_plugins_dir;
513
 
514
  $file_path = $cuef_upload_path.$blog_id."/";
515
 
519
  // delete also the subdir
520
  if (is_dir($file_path))
521
  rmdir($file_path);
522
+
523
+ // in this case no need to delete anything, per blog tables are not created
524
+ if ((is_multisite()) && ($cimy_uef_plugins_dir == "mu-plugins"))
525
+ $drop = false;
526
+
527
+ if ($drop) {
528
+ cimy_manage_db("drop_wp_fields");
529
+ cimy_manage_db("drop_extra_fields");
530
+ cimy_manage_db("drop_data");
531
+ }
532
  }
533
 
534
  function cimy_delete_users_info($fields_id) {
604
  function cimy_uef_get_meta_from_url($domain, $path) {
605
  global $wpdb;
606
 
607
+ return $wpdb->get_row($wpdb->prepare("SELECT user_login, user_email, meta FROM ".$wpdb->prefix."signups WHERE domain = %s AND path = %s AND active = %d", $domain, $path, 0), ARRAY_A);
608
  }
cimy_uef_functions.php CHANGED
@@ -459,13 +459,18 @@ function cimy_switch_to_blog($meta=array()) {
459
  $mu_blog_id = intval($_GET["blog_id"]);
460
  else if (isset($_POST["blog_id"]))
461
  $mu_blog_id = intval($_POST["blog_id"]);
 
 
 
 
 
 
 
462
  else
463
  $mu_blog_id = 1;
464
 
465
  if (cimy_uef_mu_blog_exists($mu_blog_id)) {
466
- if (switch_to_blog($mu_blog_id))
467
- cimy_uef_set_tables();
468
- else
469
  $mu_blog_id = 1;
470
  }
471
  else
@@ -473,14 +478,30 @@ function cimy_switch_to_blog($meta=array()) {
473
  }
474
  }
475
 
 
 
 
 
 
 
 
 
476
  function cimy_switch_current_blog($hidden_field=false) {
477
  global $switched, $blog_id;
478
 
479
  if (isset($switched)) {
480
- if ($hidden_field)
481
- echo "\t<input type=\"hidden\" name=\"blog_id\" value=\"".$blog_id."\" />\n";
 
 
 
 
 
 
 
482
 
483
- //restore_current_blog();
 
484
  }
485
  }
486
 
459
  $mu_blog_id = intval($_GET["blog_id"]);
460
  else if (isset($_POST["blog_id"]))
461
  $mu_blog_id = intval($_POST["blog_id"]);
462
+ // needed because WordPress 3.5+ MS doesn't like to redirect to wp-signup.php using 'blog_id' parameter
463
+ if (isset($meta["from_blog_id"]))
464
+ $mu_blog_id = intval($meta["from_blog_id"]);
465
+ else if (isset($_GET["from_blog_id"]))
466
+ $mu_blog_id = intval($_GET["from_blog_id"]);
467
+ else if (isset($_POST["from_blog_id"]))
468
+ $mu_blog_id = intval($_POST["from_blog_id"]);
469
  else
470
  $mu_blog_id = 1;
471
 
472
  if (cimy_uef_mu_blog_exists($mu_blog_id)) {
473
+ if (!switch_to_blog($mu_blog_id))
 
 
474
  $mu_blog_id = 1;
475
  }
476
  else
478
  }
479
  }
480
 
481
+ function cimy_uef_blog_switched($new_blog_id, $prev_blog_id) {
482
+ cimy_uef_set_tables();
483
+ }
484
+
485
+ function cimy_is_at_least_wordpress35() {
486
+ return version_compare(get_bloginfo('version'), '3.5') >= 0;
487
+ }
488
+
489
  function cimy_switch_current_blog($hidden_field=false) {
490
  global $switched, $blog_id;
491
 
492
  if (isset($switched)) {
493
+ if ($hidden_field) {
494
+ if (cimy_is_at_least_wordpress35()) {
495
+ echo "\t<input type=\"hidden\" name=\"from_blog_id\" value=\"".$blog_id."\" />\n";
496
+ }
497
+ else {
498
+ echo "\t<input type=\"hidden\" name=\"blog_id\" value=\"".$blog_id."\" />\n";
499
+ }
500
+
501
+ }
502
 
503
+ if (cimy_is_at_least_wordpress35())
504
+ restore_current_blog();
505
  }
506
  }
507
 
cimy_uef_init.php CHANGED
@@ -46,7 +46,6 @@ function cimy_uef_admin_init() {
46
  global $cuef_js_webpath, $cuef_plugin_dir;
47
  require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
48
  require_once($cuef_plugin_dir.'/cimy_uef_options.php');
49
- require_once($cuef_plugin_dir.'/cimy_uef_profile.php');
50
  // add code to handle new value from ajax code in A&U Extended
51
  add_action('wp_ajax_save-extra-field-new-value', 'cimy_uef_admin_ajax_save_ef_new_value');
52
 
46
  global $cuef_js_webpath, $cuef_plugin_dir;
47
  require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
48
  require_once($cuef_plugin_dir.'/cimy_uef_options.php');
 
49
  // add code to handle new value from ajax code in A&U Extended
50
  add_action('wp_ajax_save-extra-field-new-value', 'cimy_uef_admin_ajax_save_ef_new_value');
51
 
cimy_uef_register.php CHANGED
@@ -13,7 +13,7 @@ function cimy_register_user_extra_hidden_fields_stage2() {
13
  if (is_array($value))
14
  $value = implode(',', $value);
15
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
16
- } else if ($name == "blog_id") {
17
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
18
  }
19
  }
@@ -29,7 +29,7 @@ function cimy_register_user_extra_fields_signup_meta($meta) {
29
  if (is_array($value))
30
  $value = implode(',', $value);
31
  $meta[$name] = $value;
32
- } else if ($name == "blog_id") {
33
  $meta[$name] = $value;
34
  }
35
  }
@@ -81,7 +81,7 @@ function cimy_register_overwrite_password($password) {
81
  function cimy_register_user_extra_fields($user_id, $password="", $meta=array()) {
82
  global $wpdb_data_table, $wpdb, $max_length_value, $fields_name_prefix, $wp_fields_name_prefix, $wp_hidden_fields, $cimy_uef_file_types, $user_level, $cimy_uef_file_images_types;
83
 
84
- if (isset($meta["blog_id"]))
85
  cimy_switch_to_blog($meta);
86
 
87
  // avoid to save stuff if user created from wp_create_user function
@@ -317,7 +317,8 @@ function cimy_profile_check_wrapper($errors, $update, $user) {
317
  function cimy_registration_check($user_login, $user_email, $errors) {
318
  global $wpdb, $rule_canbeempty, $rule_email, $rule_maxlen, $fields_name_prefix, $wp_fields_name_prefix, $rule_equalto_case_sensitive, $apply_equalto_rule, $cimy_uef_domain, $cimy_uef_file_types, $rule_equalto_regex, $user_level, $cimy_uef_file_images_types;
319
 
320
- // cimy_switch_to_blog();
 
321
  $options = cimy_get_options();
322
 
323
  // code for confirmation email check
@@ -641,7 +642,8 @@ function cimy_registration_captcha_check($user_login, $user_email, $errors) {
641
  function cimy_registration_form($errors=null, $show_type=0) {
642
  global $wpdb, $start_cimy_uef_comment, $end_cimy_uef_comment, $rule_maxlen_needed, $fields_name_prefix, $wp_fields_name_prefix, $cuef_plugin_dir, $cimy_uef_file_types, $cimy_uef_textarea_types, $user_level, $cimy_uef_domain, $cimy_uef_file_images_types;
643
 
644
- // cimy_switch_to_blog();
 
645
 
646
  $my_user_level = $user_level;
647
 
@@ -1025,7 +1027,7 @@ function cimy_registration_form($errors=null, $show_type=0) {
1025
  $obj_id = ' id="'.$unique_id.'"';
1026
 
1027
  // tabindex not used in MU, WordPress 3.5+ and Theme My Login dropping...
1028
- if (is_multisite() || version_compare(get_bloginfo('version'), '3.5') >= 0 || (!empty($GLOBALS['theme_my_login']) && $GLOBALS['theme_my_login']->is_login_page()))
1029
  $obj_tabindex = "";
1030
  else {
1031
  $obj_tabindex = ' tabindex="'.strval($tabindex).'"';
@@ -1285,14 +1287,13 @@ function cimy_uef_redirect() {
1285
  }
1286
 
1287
  function cimy_change_signup_location($url) {
1288
- global $blog_id, $current_site, $cimy_uef_plugins_dir;
1289
 
1290
  if ($cimy_uef_plugins_dir == "plugins")
1291
- $attribute = "?blog_id=".$blog_id;
1292
  else
1293
  $attribute = "";
1294
-
1295
- return "http://" . $current_site->domain . $current_site->path . "wp-signup.php".$attribute;
1296
  }
1297
 
1298
  function cimy_change_login_registration_logo() {
13
  if (is_array($value))
14
  $value = implode(',', $value);
15
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
16
+ } else if ($name == "blog_id" || $name == "from_blog_id") {
17
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
18
  }
19
  }
29
  if (is_array($value))
30
  $value = implode(',', $value);
31
  $meta[$name] = $value;
32
+ } else if ($name == "blog_id" || $name == "from_blog_id") {
33
  $meta[$name] = $value;
34
  }
35
  }
81
  function cimy_register_user_extra_fields($user_id, $password="", $meta=array()) {
82
  global $wpdb_data_table, $wpdb, $max_length_value, $fields_name_prefix, $wp_fields_name_prefix, $wp_hidden_fields, $cimy_uef_file_types, $user_level, $cimy_uef_file_images_types;
83
 
84
+ if (isset($meta["blog_id"]) || isset($meta["from_blog_id"]))
85
  cimy_switch_to_blog($meta);
86
 
87
  // avoid to save stuff if user created from wp_create_user function
317
  function cimy_registration_check($user_login, $user_email, $errors) {
318
  global $wpdb, $rule_canbeempty, $rule_email, $rule_maxlen, $fields_name_prefix, $wp_fields_name_prefix, $rule_equalto_case_sensitive, $apply_equalto_rule, $cimy_uef_domain, $cimy_uef_file_types, $rule_equalto_regex, $user_level, $cimy_uef_file_images_types;
319
 
320
+ if (cimy_is_at_least_wordpress35())
321
+ cimy_switch_to_blog();
322
  $options = cimy_get_options();
323
 
324
  // code for confirmation email check
642
  function cimy_registration_form($errors=null, $show_type=0) {
643
  global $wpdb, $start_cimy_uef_comment, $end_cimy_uef_comment, $rule_maxlen_needed, $fields_name_prefix, $wp_fields_name_prefix, $cuef_plugin_dir, $cimy_uef_file_types, $cimy_uef_textarea_types, $user_level, $cimy_uef_domain, $cimy_uef_file_images_types;
644
 
645
+ if (cimy_is_at_least_wordpress35())
646
+ cimy_switch_to_blog();
647
 
648
  $my_user_level = $user_level;
649
 
1027
  $obj_id = ' id="'.$unique_id.'"';
1028
 
1029
  // tabindex not used in MU, WordPress 3.5+ and Theme My Login dropping...
1030
+ if (is_multisite() || cimy_is_at_least_wordpress35() || (!empty($GLOBALS['theme_my_login']) && $GLOBALS['theme_my_login']->is_login_page()))
1031
  $obj_tabindex = "";
1032
  else {
1033
  $obj_tabindex = ' tabindex="'.strval($tabindex).'"';
1287
  }
1288
 
1289
  function cimy_change_signup_location($url) {
1290
+ global $current_site, $cimy_uef_plugins_dir;
1291
 
1292
  if ($cimy_uef_plugins_dir == "plugins")
1293
+ $attribute = "?from_blog_id=".get_current_blog_id();
1294
  else
1295
  $attribute = "";
1296
+ return network_site_url('wp-signup.php'.$attribute);
 
1297
  }
1298
 
1299
  function cimy_change_login_registration_logo() {
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.4.1
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
@@ -155,11 +155,12 @@ require_once($cuef_plugin_dir.'/cimy_uef_email_handler.php');
155
  require_once($cuef_plugin_dir.'/cimy_uef_db.php');
156
  require_once($cuef_plugin_dir.'/cimy_uef_register.php');
157
  require_once($cuef_plugin_dir.'/cimy_uef_functions.php');
 
158
 
159
  add_action('admin_init', 'cimy_uef_admin_init');
160
 
161
  $cimy_uef_name = "Cimy User Extra Fields";
162
- $cimy_uef_version = "2.4.1";
163
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
164
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
165
 
@@ -461,6 +462,9 @@ if (is_multisite()) {
461
  add_action('admin_menu', 'cimy_admin_menu_custom');
462
  }
463
 
 
 
 
464
  // add action to delete all files/images when deleting a blog
465
  add_action('delete_blog', 'cimy_delete_blog_info', 10, 2);
466
 
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.2
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
155
  require_once($cuef_plugin_dir.'/cimy_uef_db.php');
156
  require_once($cuef_plugin_dir.'/cimy_uef_register.php');
157
  require_once($cuef_plugin_dir.'/cimy_uef_functions.php');
158
+ require_once($cuef_plugin_dir.'/cimy_uef_profile.php');
159
 
160
  add_action('admin_init', 'cimy_uef_admin_init');
161
 
162
  $cimy_uef_name = "Cimy User Extra Fields";
163
+ $cimy_uef_version = "2.4.2";
164
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
165
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
166
 
462
  add_action('admin_menu', 'cimy_admin_menu_custom');
463
  }
464
 
465
+ // when blog is switched we need to re-set the table's names
466
+ add_action('switch_blog', 'cimy_uef_blog_switched', 10, 2);
467
+
468
  // add action to delete all files/images when deleting a blog
469
  add_action('delete_blog', 'cimy_delete_blog_info', 10, 2);
470
 
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.4.1
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.2
9
 
10
  Add some useful fields to registration and user's info
11