Version Description
- 24.02.2012
- Bugs for multi-site WordPress network installation were discovered and fixed: 1) blocked login to admin back-end; 2) empty users list for administrators of single sites; 3) empty authors drop down list at the post editor page.
- If URE plugin is not enabled for single site administrator, then URE is automatically excluded from plugins list available to that administrator.
Download this release
Release Info
Developer | shinephp |
Plugin | User Role Editor |
Version | 3.5.1 |
Comparing to | |
See all releases |
Code changes from version 3.5 to 3.5.1
- readme.txt +6 -1
- ure-lib.php +16 -16
- ure-options.php +2 -2
- ure-role-edit.php +4 -4
- ure-user-edit.php +8 -3
- user-role-editor.php +50 -32
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: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
-
Stable tag: 3.5
|
8 |
|
9 |
User Role Editor WordPress plugin makes the role capabilities changing easy. You can change any standard WordPress user role (except administrator).
|
10 |
|
@@ -80,6 +80,11 @@ Share with me new ideas about plugin further development and link to your site w
|
|
80 |
|
81 |
|
82 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
83 |
= 3.5 =
|
84 |
* 19.02.2012
|
85 |
* User Role Editor could be available now for single site administrators (Administrator role) under multi-site environment. You should define URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE constant in your blog wp-config.php file for that. Insert this line "define('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE', 1);" there, if you decide to give single site admin such opportunity.
|
4 |
Tags: user, role, editor, security, access, permission, capability
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
+
Stable tag: 3.5.1
|
8 |
|
9 |
User Role Editor WordPress plugin makes the role capabilities changing easy. You can change any standard WordPress user role (except administrator).
|
10 |
|
80 |
|
81 |
|
82 |
== Changelog ==
|
83 |
+
= 3.5.1 =
|
84 |
+
* 24.02.2012
|
85 |
+
* Bugs for multi-site WordPress network installation were discovered and fixed: 1) blocked login to admin back-end; 2) empty users list for administrators of single sites; 3) empty authors drop down list at the post editor page.
|
86 |
+
* If URE plugin is not enabled for single site administrator, then URE is automatically excluded from plugins list available to that administrator.
|
87 |
+
|
88 |
= 3.5 =
|
89 |
* 19.02.2012
|
90 |
* User Role Editor could be available now for single site administrators (Administrator role) under multi-site environment. You should define URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE constant in your blog wp-config.php file for that. Insert this line "define('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE', 1);" there, if you decide to give single site admin such opportunity.
|
ure-lib.php
CHANGED
@@ -56,8 +56,8 @@ function ure_has_administrator_role($user_id) {
|
|
56 |
return false;
|
57 |
}
|
58 |
|
59 |
-
$tableName = defined('CUSTOM_USER_META_TABLE') ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
60 |
-
$metaKey = $wpdb->
|
61 |
$query = "SELECT count(*)
|
62 |
FROM $tableName
|
63 |
WHERE user_id=$user_id AND meta_key='$metaKey' AND meta_value like '%administrator%'";
|
@@ -148,7 +148,7 @@ function ure_getUserRoles() {
|
|
148 |
|
149 |
|
150 |
// restores User Roles from the backup record
|
151 |
-
function
|
152 |
|
153 |
global $wpdb, $wp_roles;
|
154 |
|
@@ -193,7 +193,7 @@ function restoreUserRoles() {
|
|
193 |
|
194 |
return $mess;
|
195 |
}
|
196 |
-
// end of
|
197 |
|
198 |
|
199 |
function ure_makeRolesBackup() {
|
@@ -374,11 +374,11 @@ function ure_newRoleCreate(&$ure_currentRole) {
|
|
374 |
|
375 |
|
376 |
// define roles which we could delete, e.g self-created and not used with any blog user
|
377 |
-
function
|
378 |
global $wpdb;
|
379 |
|
380 |
-
$tableName = defined('CUSTOM_USER_META_TABLE') ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
381 |
-
$metaKey = $wpdb->
|
382 |
$defaultRole = get_option('default_role');
|
383 |
$standardRoles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
|
384 |
$ure_rolesCanDelete = array();
|
@@ -677,7 +677,7 @@ function ure_AddNewCapability() {
|
|
677 |
|
678 |
|
679 |
// returns array of built-in WP capabilities (WP 3.1 wp-admin/includes/schema.php)
|
680 |
-
function
|
681 |
$caps = array();
|
682 |
$caps['switch_themes'] = 1;
|
683 |
$caps['edit_themes'] = 1;
|
@@ -747,7 +747,7 @@ function getBuiltInWPCaps() {
|
|
747 |
//
|
748 |
|
749 |
// return the array of unused capabilities
|
750 |
-
function
|
751 |
global $wp_roles, $wpdb;
|
752 |
|
753 |
// build full capabilities list from all roles except Administrator
|
@@ -763,7 +763,7 @@ function getCapsToRemove() {
|
|
763 |
}
|
764 |
}
|
765 |
|
766 |
-
$capsToExclude =
|
767 |
|
768 |
$capsToRemove = array();
|
769 |
foreach ($fullCapsList as $capability=>$value) {
|
@@ -789,8 +789,8 @@ function getCapsToRemove() {
|
|
789 |
// end of getCapsToRemove()
|
790 |
|
791 |
|
792 |
-
function
|
793 |
-
$capsToRemove =
|
794 |
if (!empty($capsToRemove) && is_array($capsToRemove) && count($capsToRemove)>0) {
|
795 |
$html = '<select id="remove_user_capability" name="remove_user_capability" width="200" style="width: 200px">';
|
796 |
foreach ($capsToRemove as $key=>$value) {
|
@@ -812,7 +812,7 @@ function ure_removeCapability() {
|
|
812 |
$mess = '';
|
813 |
if (isset($_GET['removeusercapability']) && $_GET['removeusercapability']) {
|
814 |
$capability = $_GET['removeusercapability'];
|
815 |
-
$capsToRemove =
|
816 |
if (!is_array($capsToRemove) || count($capsToRemove)==0 || !isset($capsToRemove[$capability])) {
|
817 |
return sprintf(__('Error! You do not have permission to delete this capability: %s!', 'ure'), $capability);
|
818 |
}
|
@@ -846,7 +846,7 @@ function ure_removeCapability() {
|
|
846 |
|
847 |
|
848 |
// returns link to the capability according its name in $capability parameter
|
849 |
-
function
|
850 |
|
851 |
if (empty($capability)) {
|
852 |
return '';
|
@@ -890,11 +890,11 @@ function capabilityHelpLink($capability) {
|
|
890 |
|
891 |
return $link;
|
892 |
}
|
893 |
-
// end of
|
894 |
|
895 |
|
896 |
// returns array of deprecated capabilities
|
897 |
-
function
|
898 |
|
899 |
return array('level_0'=>0, 'level_1'=>0, 'level_2'=>0, 'level_3'=>0, 'level_4'=>0, 'level_5'=>0, 'level_6'=>0, 'level_7'=>0, 'level_8'=>0, 'level_9'=>0, 'level_10'=>0);
|
900 |
|
56 |
return false;
|
57 |
}
|
58 |
|
59 |
+
$tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
60 |
+
$metaKey = $wpdb->prefix.'capabilities';
|
61 |
$query = "SELECT count(*)
|
62 |
FROM $tableName
|
63 |
WHERE user_id=$user_id AND meta_key='$metaKey' AND meta_value like '%administrator%'";
|
148 |
|
149 |
|
150 |
// restores User Roles from the backup record
|
151 |
+
function ure_restore_user_roles() {
|
152 |
|
153 |
global $wpdb, $wp_roles;
|
154 |
|
193 |
|
194 |
return $mess;
|
195 |
}
|
196 |
+
// end of ure_restore_user_roles()
|
197 |
|
198 |
|
199 |
function ure_makeRolesBackup() {
|
374 |
|
375 |
|
376 |
// define roles which we could delete, e.g self-created and not used with any blog user
|
377 |
+
function ure_getRolesCanDelete($ure_roles) {
|
378 |
global $wpdb;
|
379 |
|
380 |
+
$tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
381 |
+
$metaKey = $wpdb->prefix.'capabilities';
|
382 |
$defaultRole = get_option('default_role');
|
383 |
$standardRoles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
|
384 |
$ure_rolesCanDelete = array();
|
677 |
|
678 |
|
679 |
// returns array of built-in WP capabilities (WP 3.1 wp-admin/includes/schema.php)
|
680 |
+
function ure_getBuiltInWPCaps() {
|
681 |
$caps = array();
|
682 |
$caps['switch_themes'] = 1;
|
683 |
$caps['edit_themes'] = 1;
|
747 |
//
|
748 |
|
749 |
// return the array of unused capabilities
|
750 |
+
function ure_getCapsToRemove() {
|
751 |
global $wp_roles, $wpdb;
|
752 |
|
753 |
// build full capabilities list from all roles except Administrator
|
763 |
}
|
764 |
}
|
765 |
|
766 |
+
$capsToExclude = ure_getBuiltInWPCaps();
|
767 |
|
768 |
$capsToRemove = array();
|
769 |
foreach ($fullCapsList as $capability=>$value) {
|
789 |
// end of getCapsToRemove()
|
790 |
|
791 |
|
792 |
+
function ure_getCapsToRemoveHTML() {
|
793 |
+
$capsToRemove = ure_getCapsToRemove();
|
794 |
if (!empty($capsToRemove) && is_array($capsToRemove) && count($capsToRemove)>0) {
|
795 |
$html = '<select id="remove_user_capability" name="remove_user_capability" width="200" style="width: 200px">';
|
796 |
foreach ($capsToRemove as $key=>$value) {
|
812 |
$mess = '';
|
813 |
if (isset($_GET['removeusercapability']) && $_GET['removeusercapability']) {
|
814 |
$capability = $_GET['removeusercapability'];
|
815 |
+
$capsToRemove = ure_getCapsToRemove();
|
816 |
if (!is_array($capsToRemove) || count($capsToRemove)==0 || !isset($capsToRemove[$capability])) {
|
817 |
return sprintf(__('Error! You do not have permission to delete this capability: %s!', 'ure'), $capability);
|
818 |
}
|
846 |
|
847 |
|
848 |
// returns link to the capability according its name in $capability parameter
|
849 |
+
function ure_capability_help_link($capability) {
|
850 |
|
851 |
if (empty($capability)) {
|
852 |
return '';
|
890 |
|
891 |
return $link;
|
892 |
}
|
893 |
+
// end of ure_capability_help_link()
|
894 |
|
895 |
|
896 |
// returns array of deprecated capabilities
|
897 |
+
function ure_get_deprecated_caps() {
|
898 |
|
899 |
return array('level_0'=>0, 'level_1'=>0, 'level_2'=>0, 'level_3'=>0, 'level_4'=>0, 'level_5'=>0, 'level_6'=>0, 'level_7'=>0, 'level_8'=>0, 'level_9'=>0, 'level_10'=>0);
|
900 |
|
ure-options.php
CHANGED
@@ -26,7 +26,7 @@ if (isset($_REQUEST['action'])) {
|
|
26 |
$action = $_REQUEST['action'];
|
27 |
// restore roles capabilities from the backup record
|
28 |
if ($action=='reset') {
|
29 |
-
$mess =
|
30 |
if (!$mess) {
|
31 |
return;
|
32 |
}
|
@@ -211,7 +211,7 @@ ure_showMessage($mess);
|
|
211 |
<li><a href="http://thenineshub.com/" title="To The Nines Web Agency" target="new">To The Nines Web Agency</a></li>
|
212 |
<li><a href="http://helpkyria.com" title="http://helpkyria.com" target="new">Miami</a></li>
|
213 |
<li>quintain</li>
|
214 |
-
<li><a href="http://www.
|
215 |
<li><a href="http://www.eastwoodzhao.com" title="www.eastwoodzhao.com" target="new">Eastwood</a></li>
|
216 |
</ul>
|
217 |
<?php ure_displayBoxEnd();?>
|
26 |
$action = $_REQUEST['action'];
|
27 |
// restore roles capabilities from the backup record
|
28 |
if ($action=='reset') {
|
29 |
+
$mess = ure_restore_user_roles();
|
30 |
if (!$mess) {
|
31 |
return;
|
32 |
}
|
211 |
<li><a href="http://thenineshub.com/" title="To The Nines Web Agency" target="new">To The Nines Web Agency</a></li>
|
212 |
<li><a href="http://helpkyria.com" title="http://helpkyria.com" target="new">Miami</a></li>
|
213 |
<li>quintain</li>
|
214 |
+
<li><a href="http://www.s2member.com" title="s2member.com" target="new">s2member.com / WebSharks, Inc.</a></li>
|
215 |
<li><a href="http://www.eastwoodzhao.com" title="www.eastwoodzhao.com" target="new">Eastwood</a></li>
|
216 |
</ul>
|
217 |
<?php ure_displayBoxEnd();?>
|
ure-role-edit.php
CHANGED
@@ -41,7 +41,7 @@ $roleSelectHTML .= '</select>';
|
|
41 |
$roleDefaultHTML .= '</select>';
|
42 |
$roleToCopyHTML .= '</select>';
|
43 |
|
44 |
-
$ure_rolesCanDelete =
|
45 |
if ($ure_rolesCanDelete && count($ure_rolesCanDelete)>0) {
|
46 |
$roleDeleteHTML = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
|
47 |
foreach ($ure_rolesCanDelete as $key=>$value) {
|
@@ -52,7 +52,7 @@ if ($ure_rolesCanDelete && count($ure_rolesCanDelete)>0) {
|
|
52 |
$roleDeleteHTML = '';
|
53 |
}
|
54 |
|
55 |
-
$capabilityRemoveHTML =
|
56 |
|
57 |
?>
|
58 |
|
@@ -198,7 +198,7 @@ if (is_multisite() && is_super_admin()) {
|
|
198 |
<tr>
|
199 |
<td style="vertical-align:top;">
|
200 |
<?php
|
201 |
-
$deprecatedCaps =
|
202 |
$quant = count($ure_fullCapabilities);
|
203 |
$quantInColumn = (int) $quant/3;
|
204 |
$quantInCell = 0;
|
@@ -230,7 +230,7 @@ if (is_multisite() && is_super_admin()) {
|
|
230 |
$capIndAlt = 'human';
|
231 |
}
|
232 |
?>
|
233 |
-
<label for="<?php echo $cap_id; ?>" title="<?php echo $capability[$capIndAlt]; ?>" <?php echo $labelStyle;?> ><?php echo $capability[$capInd]; ?></label> <?php echo
|
234 |
<?php
|
235 |
$quantInCell++;
|
236 |
}
|
41 |
$roleDefaultHTML .= '</select>';
|
42 |
$roleToCopyHTML .= '</select>';
|
43 |
|
44 |
+
$ure_rolesCanDelete = ure_getRolesCanDelete($ure_roles);
|
45 |
if ($ure_rolesCanDelete && count($ure_rolesCanDelete)>0) {
|
46 |
$roleDeleteHTML = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
|
47 |
foreach ($ure_rolesCanDelete as $key=>$value) {
|
52 |
$roleDeleteHTML = '';
|
53 |
}
|
54 |
|
55 |
+
$capabilityRemoveHTML = ure_getCapsToRemoveHTML();
|
56 |
|
57 |
?>
|
58 |
|
198 |
<tr>
|
199 |
<td style="vertical-align:top;">
|
200 |
<?php
|
201 |
+
$deprecatedCaps = ure_get_deprecated_caps();
|
202 |
$quant = count($ure_fullCapabilities);
|
203 |
$quantInColumn = (int) $quant/3;
|
204 |
$quantInCell = 0;
|
230 |
$capIndAlt = 'human';
|
231 |
}
|
232 |
?>
|
233 |
+
<label for="<?php echo $cap_id; ?>" title="<?php echo $capability[$capIndAlt]; ?>" <?php echo $labelStyle;?> ><?php echo $capability[$capInd]; ?></label> <?php echo ure_capability_help_link($capability['inner']); ?><br/>
|
234 |
<?php
|
235 |
$quantInCell++;
|
236 |
}
|
ure-user-edit.php
CHANGED
@@ -71,7 +71,12 @@ $roleSelectHTML .= '</select>';
|
|
71 |
|
72 |
</script>
|
73 |
<?php
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
?>
|
77 |
<div style="float: left;"><?php echo __('Role:', 'ure').' '.$roleSelectHTML; ?></div>
|
@@ -101,7 +106,7 @@ $roleSelectHTML .= '</select>';
|
|
101 |
<tr>
|
102 |
<td style="vertical-align:top;">
|
103 |
<?php
|
104 |
-
$deprecatedCaps =
|
105 |
$quant = count($ure_fullCapabilities);
|
106 |
$quantInColumn = (int) $quant / 3;
|
107 |
$quantInCell = 0;
|
@@ -136,7 +141,7 @@ $roleSelectHTML .= '</select>';
|
|
136 |
$capIndAlt = 'human';
|
137 |
}
|
138 |
?>
|
139 |
-
<label for="<?php echo $cap_id; ?>" title="<?php echo $capability[$capIndAlt]; ?>" <?php echo $labelStyle;?> ><?php echo $capability[$capInd]; ?></label> <?php echo
|
140 |
<?php
|
141 |
$quantInCell++;
|
142 |
}
|
71 |
|
72 |
</script>
|
73 |
<?php
|
74 |
+
$userInfo = ' <span style="font-weight: bold;">'.$ure_userToEdit->user_login;
|
75 |
+
if ($ure_userToEdit->display_name!==$ure_userToEdit->user_login) {
|
76 |
+
$userInfo .= ' ('.$ure_userToEdit->display_name.')';
|
77 |
+
}
|
78 |
+
$userInfo .= '</span>';
|
79 |
+
ure_displayBoxStart(__('Change capabilities for user', 'ure').$userInfo);
|
80 |
|
81 |
?>
|
82 |
<div style="float: left;"><?php echo __('Role:', 'ure').' '.$roleSelectHTML; ?></div>
|
106 |
<tr>
|
107 |
<td style="vertical-align:top;">
|
108 |
<?php
|
109 |
+
$deprecatedCaps = ure_get_deprecated_caps();
|
110 |
$quant = count($ure_fullCapabilities);
|
111 |
$quantInColumn = (int) $quant / 3;
|
112 |
$quantInCell = 0;
|
141 |
$capIndAlt = 'human';
|
142 |
}
|
143 |
?>
|
144 |
+
<label for="<?php echo $cap_id; ?>" title="<?php echo $capability[$capIndAlt]; ?>" <?php echo $labelStyle;?> ><?php echo $capability[$capInd]; ?></label> <?php echo ure_capability_help_link($capability['inner']); ?><br/>
|
145 |
<?php
|
146 |
$quantInCell++;
|
147 |
}
|
user-role-editor.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: User Role Editor
|
4 |
Plugin URI: http://www.shinephp.com/user-role-editor-wordpress-plugin/
|
5 |
Description: It allows you to change/add/delete any WordPress user role (except administrator) capabilities list with a few clicks.
|
6 |
-
Version: 3.5
|
7 |
Author: Vladimir Garagulya
|
8 |
Author URI: http://www.shinephp.com
|
9 |
Text Domain: ure
|
@@ -108,7 +108,7 @@ function ure_admin_jquery(){
|
|
108 |
// end of ure_admin_jquery()
|
109 |
|
110 |
|
111 |
-
// We have
|
112 |
// 1st: http://blogdomain.com/wp-admin/user-edit.php?user_id=ID&wp_http_referer=%2Fwp-admin%2Fusers.php
|
113 |
// 2nd: http://blogdomain.com/wp-admin/users.php?action=delete&user=ID&_wpnonce=ab34225a78
|
114 |
// If put Administrator user ID into such request, user with lower capabilities (if he has 'edit_users')
|
@@ -146,24 +146,27 @@ function ure_not_edit_admin($allcaps, $caps, $name) {
|
|
146 |
}
|
147 |
// end of ure_not_edit_admin()
|
148 |
|
|
|
149 |
// add where criteria to exclude users with 'Administrator' role from users list
|
150 |
-
function
|
151 |
|
152 |
global $wpdb;
|
153 |
|
154 |
-
// get user_id of users with 'Administrator' role
|
155 |
-
$tableName = defined('CUSTOM_USER_META_TABLE') ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
156 |
-
$meta_key = $wpdb->
|
157 |
$admin_role_key = '%"administrator"%';
|
158 |
$query = "select user_id
|
159 |
from $tableName
|
160 |
where meta_key='$meta_key' and meta_value like '$admin_role_key'";
|
161 |
$ids_arr = $wpdb->get_col($query);
|
162 |
-
$
|
163 |
-
|
|
|
|
|
164 |
|
165 |
}
|
166 |
-
// end of
|
167 |
|
168 |
|
169 |
function exclude_admins_view($views) {
|
@@ -195,7 +198,7 @@ function ure_init() {
|
|
195 |
// prohibit any actions with user who has Administrator role
|
196 |
add_filter('user_has_cap', 'ure_not_edit_admin', 10, 3);
|
197 |
// exclude users with 'Administrator' role from users list
|
198 |
-
add_action('pre_user_query', '
|
199 |
// do not show 'Administrator (n)' view above users list
|
200 |
add_filter('views_users', 'exclude_admins_view');
|
201 |
}
|
@@ -254,10 +257,14 @@ function ure_user_row($actions, $user) {
|
|
254 |
global $pagenow, $current_user;
|
255 |
|
256 |
if ($pagenow == 'users.php') {
|
257 |
-
if (
|
258 |
-
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
|
|
261 |
} else {
|
262 |
$actions['capabilities'] = '<a href="' . wp_nonce_url("users.php?page=user-role-editor.php&object=user&user_id={$user->ID}", "ure_user_{$user->ID}") . '">' . __('Capabilities', 'ure') . '</a>';
|
263 |
}
|
@@ -293,29 +300,40 @@ if (function_exists('is_multisite') && is_multisite()) {
|
|
293 |
}
|
294 |
|
295 |
add_action( 'wpmu_new_blog', 'duplicate_roles_for_new_blog', 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
}
|
297 |
|
298 |
|
299 |
if (is_admin()) {
|
300 |
// activation action
|
301 |
-
|
302 |
-
|
303 |
-
if (empty($current_user) && function_exists('get_currentuserinfo')) {
|
304 |
-
get_currentuserinfo();
|
305 |
-
}
|
306 |
-
if (!empty($current_user)) {
|
307 |
-
$super_admins = get_super_admins();
|
308 |
-
$allow_activation = is_array( $super_admins ) && in_array( $current_user->user_login, $super_admins );
|
309 |
-
} else {
|
310 |
-
$allow_activation = false;
|
311 |
-
}
|
312 |
-
} else {
|
313 |
-
$allow_activation = true;
|
314 |
-
}
|
315 |
-
if ($allow_activation) {
|
316 |
-
register_activation_hook(__FILE__, "ure_install");
|
317 |
-
}
|
318 |
-
add_action('admin_init', 'ure_init');
|
319 |
// add a Settings link in the installed plugins page
|
320 |
add_filter('plugin_action_links', 'ure_plugin_action_links', 10, 2);
|
321 |
add_filter('plugin_row_meta', 'ure_plugin_row_meta', 10, 2);
|
3 |
Plugin Name: User Role Editor
|
4 |
Plugin URI: http://www.shinephp.com/user-role-editor-wordpress-plugin/
|
5 |
Description: It allows you to change/add/delete any WordPress user role (except administrator) capabilities list with a few clicks.
|
6 |
+
Version: 3.5.1
|
7 |
Author: Vladimir Garagulya
|
8 |
Author URI: http://www.shinephp.com
|
9 |
Text Domain: ure
|
108 |
// end of ure_admin_jquery()
|
109 |
|
110 |
|
111 |
+
// We have two vulnerable queries id users admin interface which should be processed
|
112 |
// 1st: http://blogdomain.com/wp-admin/user-edit.php?user_id=ID&wp_http_referer=%2Fwp-admin%2Fusers.php
|
113 |
// 2nd: http://blogdomain.com/wp-admin/users.php?action=delete&user=ID&_wpnonce=ab34225a78
|
114 |
// If put Administrator user ID into such request, user with lower capabilities (if he has 'edit_users')
|
146 |
}
|
147 |
// end of ure_not_edit_admin()
|
148 |
|
149 |
+
|
150 |
// add where criteria to exclude users with 'Administrator' role from users list
|
151 |
+
function ure_exclude_administrators($user_query) {
|
152 |
|
153 |
global $wpdb;
|
154 |
|
155 |
+
// get user_id of users with 'Administrator' role
|
156 |
+
$tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
157 |
+
$meta_key = $wpdb->prefix.'capabilities';
|
158 |
$admin_role_key = '%"administrator"%';
|
159 |
$query = "select user_id
|
160 |
from $tableName
|
161 |
where meta_key='$meta_key' and meta_value like '$admin_role_key'";
|
162 |
$ids_arr = $wpdb->get_col($query);
|
163 |
+
if (is_array($ids_arr) && count($ids_arr)>0) {
|
164 |
+
$ids = implode(',', $ids_arr);
|
165 |
+
$user_query->query_where .= " AND ($wpdb->users.ID NOT IN ($ids))";
|
166 |
+
}
|
167 |
|
168 |
}
|
169 |
+
// end of ure_exclude_administrators()
|
170 |
|
171 |
|
172 |
function exclude_admins_view($views) {
|
198 |
// prohibit any actions with user who has Administrator role
|
199 |
add_filter('user_has_cap', 'ure_not_edit_admin', 10, 3);
|
200 |
// exclude users with 'Administrator' role from users list
|
201 |
+
add_action('pre_user_query', 'ure_exclude_administrators');
|
202 |
// do not show 'Administrator (n)' view above users list
|
203 |
add_filter('views_users', 'exclude_admins_view');
|
204 |
}
|
257 |
global $pagenow, $current_user;
|
258 |
|
259 |
if ($pagenow == 'users.php') {
|
260 |
+
if (is_super_admin() ||
|
261 |
+
(is_multisite() && defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE==1 && current_user_can('administrator'))) {
|
262 |
+
if (isset($user->caps['administrator'])) {
|
263 |
+
if ($current_user->ID!=$user->ID) {
|
264 |
+
unset($actions['edit']);
|
265 |
+
unset($actions['delete']);
|
266 |
+
unset($actions['remove']);
|
267 |
+
}
|
268 |
} else {
|
269 |
$actions['capabilities'] = '<a href="' . wp_nonce_url("users.php?page=user-role-editor.php&object=user&user_id={$user->ID}", "ure_user_{$user->ID}") . '">' . __('Capabilities', 'ure') . '</a>';
|
270 |
}
|
300 |
}
|
301 |
|
302 |
add_action( 'wpmu_new_blog', 'duplicate_roles_for_new_blog', 10, 2 );
|
303 |
+
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Filter out URE plugin from not superadmin users
|
307 |
+
* @param type array $plugins plugins list
|
308 |
+
* @return type array $plugins updated plugins list
|
309 |
+
*/
|
310 |
+
function ure_exclude_from_plugins_list($plugins) {
|
311 |
+
|
312 |
+
// if multi-site, then allow plugin activation for network superadmins and, if that's specially defined, - for single site administrators too
|
313 |
+
if (is_super_admin() || (defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE==1)) {
|
314 |
+
return $plugins;
|
315 |
+
}
|
316 |
+
|
317 |
+
// exclude URE from plugins list
|
318 |
+
foreach ($plugins as $key => $value) {
|
319 |
+
if ($key == 'user-role-editor/user-role-editor.php') {
|
320 |
+
unset($plugins[$key]);
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
return $plugins;
|
325 |
+
}
|
326 |
+
// end of ure_exclude_from_plugins_list()
|
327 |
+
|
328 |
+
add_filter( 'all_plugins', 'ure_exclude_from_plugins_list' );
|
329 |
+
|
330 |
}
|
331 |
|
332 |
|
333 |
if (is_admin()) {
|
334 |
// activation action
|
335 |
+
register_activation_hook(__FILE__, "ure_install");
|
336 |
+
add_action('admin_init', 'ure_init');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
// add a Settings link in the installed plugins page
|
338 |
add_filter('plugin_action_links', 'ure_plugin_action_links', 10, 2);
|
339 |
add_filter('plugin_row_meta', 'ure_plugin_row_meta', 10, 2);
|