Change WordPress user roles and capabilities › Forums › Bug Reports › ure_manage_options tied to Administrator visibility
Tagged: Administrator, capability, ure_manage_options
- This topic has 8 replies, 2 voices, and was last updated 6 years, 5 months ago by Vladimir.
-
AuthorPosts
-
22/06/2018 at 07:57 #4961tannerParticipant
It seems if I remove the ure_manage_options capability from a Role, that Role is unable to see any Administrator Users in the Users list and unable to assign anyone to the Administrator Role.
23/06/2018 at 11:19 #4968VladimirKeymasterRight. I explained that URE hides ‘administrator’ role and users with ‘administrator’ role by default from any user without ‘administrator’ role at your previous topic. More – URE hides all users with administrator role from any other user with ‘administrator’ role. This protection measure does not take effect for the WordPress built-in superadmin with ID=1.
User with ‘ure_manage_options’ capability is a superadmin for User Role Editor. So admin protection does not applied for such user too.
If you wish to switch this logic off use URE’s custom filter ‘ure_supress_administrators_protection’.
add_filter('ure_supress_administrators_protection', 'switch_off_ure_administrators_protection', 10, 1); function switch_off_ure_administrators_protection($supress_protection) { $supress_protection = true; return $supress_protection; }
Similar topic was discussed at this thread.
25/06/2018 at 09:19 #4973tannerParticipantMore – URE hides all users with administrator role from any other user with ‘administrator’ role.
By default, without URE, an
administrator
user can see all otheradministrator
users. So why is URE blocking the view of otheradministrator
users if they do not haveure_manage_options
capability?ure_manage_options
is specific to URE.25/06/2018 at 18:02 #4976tannerParticipantI’ve just tried adding
add_filter('ure_supress_administrators_protection', 'switch_off_ure_administrators_protection', 10, 1); function switch_off_ure_administrators_protection($supress_protection) { $supress_protection = true; return $supress_protection; }
to the functions.php file for testing gbt it crashes the site.
26/06/2018 at 03:31 #4977VladimirKeymasterError messages from the server logs will be useful in this case.
I made another test – code works without error. You can send your own functions.php to support [at-sign] role-editor.com. I will look what may be wrong with your version.26/06/2018 at 21:50 #4982tannerParticipantGot this to work. It had to do with my use of
is_plugin_active
. Not sure why that was erroring out but opted in to usingif ( defined('URE_VERSION'))
instead27/06/2018 at 01:32 #4985VladimirKeymasterOK.
wp-admin/includes/plugin.php
may be not loaded at the point you tried to callis_plugin_active()
, if you called it beyond function, hooked to the action.01/07/2018 at 21:57 #5000tannerParticipantNot sure if you can help me here, I’ve been getting a ton of PHP warnings:
[01-Jul-2018 21:54:09 UTC] PHP Warning: in_array() expects parameter 2 to be array, null given in .../wp-content/mu-plugins/ure-assist/ure-assist.php on line 26 [01-Jul-2018 21:54:09 UTC] PHP Notice: Undefined variable: user in .../wp-content/mu-plugins/ure-assist/ure-assist.php on line 26 [01-Jul-2018 21:54:09 UTC] PHP Notice: Trying to get property of non-object in .../wp-content/mu-plugins/ure-assist/ure-assist.php on line 26
This is my MU plugin..
<?php if ( is_admin() ) { add_action('plugins_loaded', 'ure_loaded'); function ure_loaded() { if ( defined('URE_VERSION') ) { global $pagenow; $user = wp_get_current_user(); if (!in_array('webmaster', $user->roles)){ add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section'); add_filter('ure_bulk_grant_roles', 'ure_show_additional_capabilities_section'); function ure_show_additional_capabilities_section($show) { if (in_array('admin', $user->roles) || in_array('administrator', $user->roles)) { $show = false; } return $show; } if ($pagenow == 'users.php') { add_action('admin_enqueue_scripts', 'load_admin_style'); function load_admin_style() { wp_register_style('ure-styles', plugins_url( '/css/admin.css', __FILE__ ) ); wp_enqueue_style('ure-styles'); } } } elseif (in_array('webmaster', $user->roles)) { add_filter('ure_supress_administrators_protection', 'remove_ure_administrator_protection', 10, 1); function remove_ure_administrator_protection($supress_protection) { $supress_protection = true; return $supress_protection; } } } } }
Any ideas?
02/07/2018 at 04:00 #5001VladimirKeymasterVariable $user is not defined inside function
ure_show_additional_capabilities_section()
.
This version will fix the issue:function ure_show_additional_capabilities_section($show) { $user = wp_get_current_user(); if (in_array('admin', $user->roles) || in_array('administrator', $user->roles)) { $show = false; } return $show; }
-
AuthorPosts
- You must be logged in to reply to this topic.