User Role Editor - Version 4.25

Version Description

Download this release

Release Info

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

Code changes from version 4.24 to 4.25

includes/class-role-additional-options.php CHANGED
@@ -90,7 +90,7 @@ class URE_Role_Additional_Options {
90
  }
91
  foreach(array_keys($this->active_items[$role]) as $item_id) {
92
  if (isset($this->items[$item_id])) {
93
- add_action($this->items[$item_id]->hook, $this->items[$item_id]->routine);
94
  }
95
  }
96
  }
90
  }
91
  foreach(array_keys($this->active_items[$role]) as $item_id) {
92
  if (isset($this->items[$item_id])) {
93
+ add_action($this->items[$item_id]->hook, $this->items[$item_id]->routine, 99);
94
  }
95
  }
96
  }
includes/class-user-other-roles.php CHANGED
@@ -242,6 +242,11 @@ class URE_User_Other_Roles {
242
  // save additional user roles when user profile is updated, as WordPress itself doesn't know about them
243
  public function update($user_id) {
244
 
 
 
 
 
 
245
  if (!current_user_can('edit_user', $user_id)) {
246
  return false;
247
  }
@@ -251,17 +256,18 @@ class URE_User_Other_Roles {
251
  return false;
252
  }
253
 
254
- $ure_other_roles = explode(',', str_replace(' ', '', $_POST['ure_other_roles']));
255
- $new_roles = array_intersect($user->roles, $ure_other_roles);
256
- $skip_roles = array();
257
- foreach ($new_roles as $role) {
258
- $skip_roles['$role'] = 1;
 
 
 
 
259
  }
260
- unset($new_roles);
261
  foreach ($ure_other_roles as $role) {
262
- if (!isset($skip_roles[$role])) {
263
- $user->add_role($role);
264
- }
265
  }
266
 
267
  return true;
242
  // save additional user roles when user profile is updated, as WordPress itself doesn't know about them
243
  public function update($user_id) {
244
 
245
+ global $wp_roles;
246
+
247
+ if (!current_user_can('edit_users')) {
248
+ return false;
249
+ }
250
  if (!current_user_can('edit_user', $user_id)) {
251
  return false;
252
  }
256
  return false;
257
  }
258
 
259
+ $data = explode(',', str_replace(' ', '', $_POST['ure_other_roles']));
260
+ $ure_other_roles = array();
261
+ foreach($data as $role_id) {
262
+ if (!isset($wp_roles->roles[$role_id])) { // skip unexisted roles
263
+ continue;
264
+ }
265
+ if (is_array($user->roles) && !in_array($role_id, $user->roles)) {
266
+ $ure_other_roles[] = $role_id;
267
+ }
268
  }
 
269
  foreach ($ure_other_roles as $role) {
270
+ $user->add_role($role);
 
 
271
  }
272
 
273
  return true;
includes/class-user-role-editor.php CHANGED
@@ -206,11 +206,7 @@ class User_Role_Editor {
206
  &nbsp;&nbsp;<input type="button" name="move_from_no_role" id="move_from_no_role" class="button"
207
  value="Without role (<?php echo $users_quant;?>)" onclick="ure_move_users_from_no_role_dialog()">
208
  <div id="move_from_no_role_dialog" class="ure-dialog">
209
- <div id="move_from_no_role_content" style="padding: 10px;">
210
- To: <select name="ure_new_role" id="ure_new_role">
211
- <option value="no_rights">No rights</option>
212
- </select><br>
213
- </div>
214
  </div>
215
  <?php
216
  }
@@ -249,6 +245,7 @@ class User_Role_Editor {
249
  wp_localize_script( 'ure-users-js', 'ure_users_data', array(
250
  'wp_nonce' => wp_create_nonce('user-role-editor'),
251
  'move_from_no_role_title' => esc_html__('Change role for users without role', 'user-role-editor'),
 
252
  'no_rights_caption' => esc_html__('No rights', 'user-role-editor'),
253
  'provide_new_role_caption' => esc_html__('Provide new role', 'user-role-editor')
254
  ));
206
  &nbsp;&nbsp;<input type="button" name="move_from_no_role" id="move_from_no_role" class="button"
207
  value="Without role (<?php echo $users_quant;?>)" onclick="ure_move_users_from_no_role_dialog()">
208
  <div id="move_from_no_role_dialog" class="ure-dialog">
209
+ <div id="move_from_no_role_content" style="padding: 10px;"></div>
 
 
 
 
210
  </div>
211
  <?php
212
  }
245
  wp_localize_script( 'ure-users-js', 'ure_users_data', array(
246
  'wp_nonce' => wp_create_nonce('user-role-editor'),
247
  'move_from_no_role_title' => esc_html__('Change role for users without role', 'user-role-editor'),
248
+ 'to' => esc_html__('To:', 'user-role-editor'),
249
  'no_rights_caption' => esc_html__('No rights', 'user-role-editor'),
250
  'provide_new_role_caption' => esc_html__('Provide new role', 'user-role-editor')
251
  ));
includes/classes/ure-lib.php CHANGED
@@ -384,7 +384,7 @@ if ($this->multisite && !is_network_admin()) {
384
  ?>
385
  <div class="wrap">
386
  <div id="ure-icon" class="icon32"><br/></div>
387
- <h2><?php _e('User Role Editor', 'user-role-editor'); ?></h2>
388
  <div id="ure_container" style="min-width: <?php echo $container_width;?>px;">
389
  <div class="ure-sidebar" >
390
  <?php
384
  ?>
385
  <div class="wrap">
386
  <div id="ure-icon" class="icon32"><br/></div>
387
+ <h1><?php _e('User Role Editor', 'user-role-editor'); ?></h1>
388
  <div id="ure_container" style="min-width: <?php echo $container_width;?>px;">
389
  <div class="ure-sidebar" >
390
  <?php
includes/settings-template.php CHANGED
@@ -14,7 +14,7 @@
14
  <a href="http://role-editor.com">
15
  <div id="ure-icon" class="icon32"><br></div>
16
  </a>
17
- <h2><?php esc_html_e('User Role Editor - Options', 'user-role-editor'); ?></h2>
18
 
19
  <div id="ure_tabs" style="clear: left;">
20
  <ul>
14
  <a href="http://role-editor.com">
15
  <div id="ure-icon" class="icon32"><br></div>
16
  </a>
17
+ <h1><?php esc_html_e('User Role Editor - Options', 'user-role-editor'); ?></h1>
18
 
19
  <div id="ure_tabs" style="clear: left;">
20
  <ul>
js/ure-users.js CHANGED
@@ -1,6 +1,8 @@
1
  /* User Role Editor for users.php */
2
 
3
- jQuery(document).ready(function() {
 
 
4
  var options = jQuery("#new_role > option").clone();
5
  jQuery('#ure_new_role').empty().append(options);
6
  if (jQuery('#ure_new_role option[value="no_rights"]').length === 0) {
@@ -8,18 +10,18 @@ jQuery(document).ready(function() {
8
  }
9
 
10
  // Exclude change role to
11
- jQuery('#selectBox option[value=""]').remove();
12
  var new_role = jQuery('#new_role').find(":selected").val();
13
  if (new_role.length > 0) {
14
- jQuery("#ure_new_role").val(new_role);
15
  }
16
- jQuery('#ure_new_role').trigger('updated');
17
  });
18
 
19
 
20
 
21
  function ure_move_users_from_no_role_dialog() {
22
-
23
  jQuery('#move_from_no_role_dialog').dialog({
24
  dialogClass: 'wp-dialog',
25
  modal: true,
@@ -32,7 +34,7 @@ function ure_move_users_from_no_role_dialog() {
32
  'buttons': {
33
  'OK': function () {
34
  ure_move_users_from_no_role();
35
-
36
  },
37
  Cancel: function () {
38
  jQuery(this).dialog('close');
@@ -45,7 +47,7 @@ function ure_move_users_from_no_role_dialog() {
45
 
46
 
47
  function ure_move_users_from_no_role() {
48
- new_role = jQuery('#ure_new_role').find(":selected").val();
49
  if (new_role.length==0) {
50
  alert(ure_users_data.provide_new_role_caption);
51
  return;
1
  /* User Role Editor for users.php */
2
 
3
+ jQuery(document).ready(function() {
4
+ jQuery('#move_from_no_role_content').append(ure_users_data.to +' <select id="ure_new_role" name="ure_new_role"></select>');
5
+ var ure_new_role = jQuery('#ure_new_role');
6
  var options = jQuery("#new_role > option").clone();
7
  jQuery('#ure_new_role').empty().append(options);
8
  if (jQuery('#ure_new_role option[value="no_rights"]').length === 0) {
10
  }
11
 
12
  // Exclude change role to
13
+ jQuery('#ure_new_role option[value=""]').remove();
14
  var new_role = jQuery('#new_role').find(":selected").val();
15
  if (new_role.length > 0) {
16
+ ure_new_role.val(new_role);
17
  }
18
+ ure_new_role.trigger('updated');
19
  });
20
 
21
 
22
 
23
  function ure_move_users_from_no_role_dialog() {
24
+
25
  jQuery('#move_from_no_role_dialog').dialog({
26
  dialogClass: 'wp-dialog',
27
  modal: true,
34
  'buttons': {
35
  'OK': function () {
36
  ure_move_users_from_no_role();
37
+ jQuery(this).dialog('close');
38
  },
39
  Cancel: function () {
40
  jQuery(this).dialog('close');
47
 
48
 
49
  function ure_move_users_from_no_role() {
50
+ var new_role = jQuery('#ure_new_role').find(":selected").val();
51
  if (new_role.length==0) {
52
  alert(ure_users_data.provide_new_role_caption);
53
  return;
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.5
7
- Stable tag: 4.24
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -36,7 +36,7 @@ Do you need more functionality with quality support in the real time? Do you wis
36
  <li>"Export/Import" module. You can export user roles to the local file and import them then to any WordPress site or other sites of the multi-site WordPress network.</li>
37
  <li>Roles and Users permissions management via Network Admin for multisite configuration. One click Synchronization to the whole network.</li>
38
  <li>"Other roles access" module allows to define which other roles user with current role may see at WordPress: dropdown menus, e.g assign role to user editing user profile, etc.</li>
39
- <li>Per posts/pages users access management to post/page editing functionality.</li>
40
  <li>Per plugin users access management for plugins activate/deactivate operations.</li>
41
  <li>Per form users access management for Gravity Forms plugin.</li>
42
  <li>Shortcode to show enclosed content to the users with selected roles only.</li>
@@ -76,11 +76,18 @@ If you wish to check available translations or help with plugin translation to y
76
  https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
77
 
78
  == Changelog ==
 
 
 
 
 
 
 
79
  = [4.24] 17.03.2016 =
80
  * Fix: PHP notice was generated by class-role-additional-options.php in case when some option does not exist anymore
81
  * Enhance: 'Add Capability' button have added capability to the WordPress built-in administrator role by default. It did not work, if 'administrator' role did not exist.
82
  Now script selects automatically as an admin role a role with the largest quant of capabilities and adds new capability to the selected role.
83
- * New: User capabilities page was integrated with "[User Switching](https://wordpress.org/plugins/user-switching/)" plugin - "Switch To" the editing user link is added if "User Switching" plugin is available.
84
  * Marked as compatible with WordPress 4.5.
85
 
86
  = [4.23.2] 03.02.2016 =
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
  Tested up to: 4.5
7
+ Stable tag: 4.25
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
36
  <li>"Export/Import" module. You can export user roles to the local file and import them then to any WordPress site or other sites of the multi-site WordPress network.</li>
37
  <li>Roles and Users permissions management via Network Admin for multisite configuration. One click Synchronization to the whole network.</li>
38
  <li>"Other roles access" module allows to define which other roles user with current role may see at WordPress: dropdown menus, e.g assign role to user editing user profile, etc.</li>
39
+ <li>Manage user access to editing posts/pages/custom post type using posts/pages, authors, taxonomies ID list.</li>
40
  <li>Per plugin users access management for plugins activate/deactivate operations.</li>
41
  <li>Per form users access management for Gravity Forms plugin.</li>
42
  <li>Shortcode to show enclosed content to the users with selected roles only.</li>
76
  https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
77
 
78
  == Changelog ==
79
+ = [4.25] 02.04.2016 =
80
+ * Important security update: Any registered user could get an administrator access. Thanks to [John Muncaster](http://johnmuncaster.com/) for discovering and wisely reporting it.
81
+ * URE pages title tag was replaced from h2 to h1, for compatibility with other WordPress pages.
82
+ * Fix: "Assign role to the users without role" feature ignored role selected by user.
83
+ * Fix: PHP fatal error (line 34) was raised at uninstall.php for WordPress multisite.
84
+ * Update: action priority 99 was added for role additional options hook action setup.
85
+
86
  = [4.24] 17.03.2016 =
87
  * Fix: PHP notice was generated by class-role-additional-options.php in case when some option does not exist anymore
88
  * Enhance: 'Add Capability' button have added capability to the WordPress built-in administrator role by default. It did not work, if 'administrator' role did not exist.
89
  Now script selects automatically as an admin role a role with the largest quant of capabilities and adds new capability to the selected role.
90
+ * New: User capabilities page was integrated with "[User Switching](https://wordpress.org/plugins/user-switching/)" plugin - "Switch To" the editing user link iss added if "User Switching" plugin is available.
91
  * Marked as compatible with WordPress 4.5.
92
 
93
  = [4.23.2] 03.02.2016 =
uninstall.php CHANGED
@@ -5,6 +5,7 @@
5
  *
6
  */
7
 
 
8
 
9
  if (!defined('ABSPATH') || !defined('WP_UNINSTALL_PLUGIN')) {
10
  exit(); // silence is golden
5
  *
6
  */
7
 
8
+ global $wpdb;
9
 
10
  if (!defined('ABSPATH') || !defined('WP_UNINSTALL_PLUGIN')) {
11
  exit(); // silence is golden
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.24
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.24');
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.25
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.25');
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__));