User Role Editor - Version 4.35.3

Version Description

Download this release

Release Info

Developer shinephp
Plugin Icon 128x128 User Role Editor
Version 4.35.3
Comparing to
See all releases

Code changes from version 4.35.2 to 4.35.3

includes/classes/user-other-roles.php CHANGED
@@ -12,7 +12,7 @@
12
  class URE_User_Other_Roles {
13
 
14
  protected $lib = null;
15
-
16
 
17
  function __construct() {
18
 
@@ -36,6 +36,7 @@ class URE_User_Other_Roles {
36
  $multisite = $this->lib->get('multisite');
37
  if ($multisite) {
38
  add_action( 'wpmu_activate_user', array($this, 'add_other_roles'), 10, 1 );
 
39
  }
40
  add_action( 'user_register', array($this, 'add_other_roles'), 10, 1 );
41
 
@@ -133,14 +134,15 @@ class URE_User_Other_Roles {
133
  if (isset($roles[$primary_role])) { // exclude role assigned to the user as a primary role
134
  unset($roles[$primary_role]);
135
  }
136
-
137
- echo '<select multiple="multiple" id="ure_select_other_roles" name="ure_select_other_roles" style="width: 500px;" >'."\n";
 
138
  foreach($roles as $key=>$role) {
139
  echo '<option value="'.$key.'" >'.$role['name'].'</option>'."\n";
140
  } // foreach()
141
  echo '</select><br>'."\n";
142
 
143
- if ($context=='add-new-user') {
144
  // Get other default roles
145
  $other_roles = $this->lib->get_option('other_default_roles', array());
146
  } else {
@@ -151,11 +153,13 @@ class URE_User_Other_Roles {
151
  } else {
152
  $other_roles_str = '';
153
  }
154
- echo '<input type="hidden" name="ure_other_roles" id="ure_other_roles" value="' . $other_roles_str . '" />';
155
 
156
 
157
  $output = $this->lib->roles_text($other_roles);
158
- echo '<span id="ure_other_roles_list">'. $output .'</span>';
 
 
159
  }
160
  // end of roles_select()
161
 
@@ -321,7 +325,6 @@ class URE_User_Other_Roles {
321
  }
322
  // end of add_other_roles()
323
 
324
-
325
-
326
  }
327
  // end of URE_User_Other_Roles class
12
  class URE_User_Other_Roles {
13
 
14
  protected $lib = null;
15
+ private static $counter = 0;
16
 
17
  function __construct() {
18
 
36
  $multisite = $this->lib->get('multisite');
37
  if ($multisite) {
38
  add_action( 'wpmu_activate_user', array($this, 'add_other_roles'), 10, 1 );
39
+ add_action( 'added_existing_user', array($this, 'add_other_roles'), 10, 1);
40
  }
41
  add_action( 'user_register', array($this, 'add_other_roles'), 10, 1 );
42
 
134
  if (isset($roles[$primary_role])) { // exclude role assigned to the user as a primary role
135
  unset($roles[$primary_role]);
136
  }
137
+ $button_number = (self::$counter>0) ? '_2': '';
138
+
139
+ echo '<select multiple="multiple" id="ure_select_other_roles'. $button_number .'" name="ure_select_other_roles" style="width: 500px;" >'."\n";
140
  foreach($roles as $key=>$role) {
141
  echo '<option value="'.$key.'" >'.$role['name'].'</option>'."\n";
142
  } // foreach()
143
  echo '</select><br>'."\n";
144
 
145
+ if ($context=='add-new-user' || $context=='add-existing-user') {
146
  // Get other default roles
147
  $other_roles = $this->lib->get_option('other_default_roles', array());
148
  } else {
153
  } else {
154
  $other_roles_str = '';
155
  }
156
+ echo '<input type="hidden" name="ure_other_roles" id="ure_other_roles'. $button_number .'" value="' . $other_roles_str . '" />';
157
 
158
 
159
  $output = $this->lib->roles_text($other_roles);
160
+ echo '<span id="ure_other_roles_list'. $button_number .'">'. $output .'</span>';
161
+
162
+ self::$counter++;
163
  }
164
  // end of roles_select()
165
 
325
  }
326
  // end of add_other_roles()
327
 
328
+
 
329
  }
330
  // end of URE_User_Other_Roles class
js/ure-user-profile-other-roles.js CHANGED
@@ -3,8 +3,16 @@
3
  * email: support@role-editor.com
4
  */
5
 
6
- jQuery(document).ready(function(){
7
- if (jQuery('#ure_select_other_roles').length==0) {
 
 
 
 
 
 
 
 
8
  return;
9
  }
10
 
@@ -12,7 +20,7 @@ jQuery(document).ready(function(){
12
  jQuery('.user-role-wrap').hide();
13
  }
14
 
15
- jQuery('#ure_select_other_roles').multipleSelect({
16
  filter: true,
17
  multiple: true,
18
  selectAll: false,
@@ -20,19 +28,18 @@ jQuery(document).ready(function(){
20
  maxHeight: 300,
21
  placeholder: ure_data_user_profile_other_roles.select_roles,
22
  onClick: function(view) {
23
- ure_update_linked_controls_other_roles();
24
  }
25
  });
26
 
27
- var other_roles = jQuery('#ure_other_roles').val();
28
  var selected_roles = other_roles.split(',');
29
- jQuery('#ure_select_other_roles').multipleSelect('setSelects', selected_roles);
30
-
31
- });
32
 
33
 
34
- function ure_update_linked_controls_other_roles() {
35
- var data_value = jQuery('#ure_select_other_roles').multipleSelect('getSelects');
36
  var to_save = '';
37
  for (i=0; i<data_value.length; i++) {
38
  if (to_save!=='') {
@@ -40,9 +47,9 @@ function ure_update_linked_controls_other_roles() {
40
  }
41
  to_save = to_save + data_value[i];
42
  }
43
- jQuery('#ure_other_roles').val(to_save);
44
 
45
- var data_text = jQuery('#ure_select_other_roles').multipleSelect('getSelects', 'text');
46
  var to_show = '';
47
  for (i=0; i<data_text.length; i++) {
48
  if (to_show!=='') {
@@ -50,5 +57,5 @@ function ure_update_linked_controls_other_roles() {
50
  }
51
  to_show = to_show + data_text[i];
52
  }
53
- jQuery('#ure_other_roles_list').html(to_show);
54
  }
3
  * email: support@role-editor.com
4
  */
5
 
6
+ jQuery(document).ready(function() {
7
+
8
+ ure_init_controls('');
9
+ ure_init_controls('_2');
10
+
11
+ });
12
+
13
+
14
+ function ure_init_controls(context) {
15
+ if (jQuery('#ure_select_other_roles'+ context).length==0) {
16
  return;
17
  }
18
 
20
  jQuery('.user-role-wrap').hide();
21
  }
22
 
23
+ jQuery('#ure_select_other_roles'+ context).multipleSelect({
24
  filter: true,
25
  multiple: true,
26
  selectAll: false,
28
  maxHeight: 300,
29
  placeholder: ure_data_user_profile_other_roles.select_roles,
30
  onClick: function(view) {
31
+ ure_update_linked_controls_other_roles(context);
32
  }
33
  });
34
 
35
+ var other_roles = jQuery('#ure_other_roles'+ context).val();
36
  var selected_roles = other_roles.split(',');
37
+ jQuery('#ure_select_other_roles'+ context).multipleSelect('setSelects', selected_roles);
38
+ }
 
39
 
40
 
41
+ function ure_update_linked_controls_other_roles(context) {
42
+ var data_value = jQuery('#ure_select_other_roles'+ context).multipleSelect('getSelects');
43
  var to_save = '';
44
  for (i=0; i<data_value.length; i++) {
45
  if (to_save!=='') {
47
  }
48
  to_save = to_save + data_value[i];
49
  }
50
+ jQuery('#ure_other_roles'+ context).val(to_save);
51
 
52
+ var data_text = jQuery('#ure_select_other_roles'+ context).multipleSelect('getSelects', 'text');
53
  var to_show = '';
54
  for (i=0; i<data_text.length; i++) {
55
  if (to_show!=='') {
57
  }
58
  to_show = to_show + data_text[i];
59
  }
60
+ jQuery('#ure_other_roles_list'+ context).html(to_show);
61
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladi
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
- Stable tag: 4.35.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -79,8 +79,11 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
79
 
80
  == Changelog =
81
 
 
 
 
82
  = [4.35.2] 18.07.2017 =
83
- * Fix: Multiple default roles (if defined at URE's settings) are selected automatically at 'add-new-user' page.
84
  * Update: Code enhancement for protection of users with 'administrator' role from each other. Current user can see his own record and edit own profile.
85
 
86
  = [4.35.1] 10.07.2017 =
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
+ Stable tag: 4.35.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
79
 
80
  == Changelog =
81
 
82
+ = [4.35.3] 20.07.2017 =
83
+ * Fix: Multiple roles assignment (including default roles) did not work at "Users->Add New" new-user.php (contexts: add-existing-user, add-new-user) page for WordPress multisite.
84
+
85
  = [4.35.2] 18.07.2017 =
86
+ * Fix: Multiple default roles (if defined at URE's settings) are selected automatically at new-user.php (context: add-new-user) page.
87
  * Update: Code enhancement for protection of users with 'administrator' role from each other. Current user can see his own record and edit own profile.
88
 
89
  = [4.35.1] 10.07.2017 =
user-role-editor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: User Role Editor
4
  Plugin URI: https://www.role-editor.com
5
  Description: Change/add/delete WordPress user roles and capabilities.
6
- Version: 4.35.2
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: ure
@@ -23,7 +23,7 @@ if (defined('URE_PLUGIN_URL')) {
23
  wp_die('It seems that other version of User Role Editor is active. Please deactivate it before use this version');
24
  }
25
 
26
- define('URE_VERSION', '4.35.2');
27
  define('URE_PLUGIN_URL', plugin_dir_url(__FILE__));
28
  define('URE_PLUGIN_DIR', plugin_dir_path(__FILE__));
29
  define('URE_PLUGIN_BASE_NAME', plugin_basename(__FILE__));
3
  Plugin Name: User Role Editor
4
  Plugin URI: https://www.role-editor.com
5
  Description: Change/add/delete WordPress user roles and capabilities.
6
+ Version: 4.35.3
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: ure
23
  wp_die('It seems that other version of User Role Editor is active. Please deactivate it before use this version');
24
  }
25
 
26
+ define('URE_VERSION', '4.35.3');
27
  define('URE_PLUGIN_URL', plugin_dir_url(__FILE__));
28
  define('URE_PLUGIN_DIR', plugin_dir_path(__FILE__));
29
  define('URE_PLUGIN_BASE_NAME', plugin_basename(__FILE__));