Change WordPress user roles and capabilities › Forums › Give user access to plugin – how to › Restrict Access to User Role Editor for Multisite Users
- This topic has 3 replies, 2 voices, and was last updated 8 years, 5 months ago by Vladimir.
-
AuthorPosts
-
13/06/2016 at 20:18 #2412prolificParticipant
Hello,
I’m needing help restricting access to, ironically enough, the User Role Editor plugin. I’m not sure how to do it within the plugin, but I was able to hide the menus by coding it in with remove_submenu_page() (restricting actual access is not really necessary).
if ( !current_user_can('activate_plugins') ) { remove_submenu_page( 'users.php', 'users-user-role-editor-pro.php' ); remove_submenu_page( 'settings.php', 'settings-user-role-editor-pro.php' ); }
However, I also gave some users limited access to network functionality, so I would also like to remove the plugin menus from that navigation. The above code does not work for this. I tried adding “network/” in front of the parent menu slug, but it didn’t help.
Thoughts?
Thanks!
Luke14/06/2016 at 03:18 #2413VladimirKeymasterHi Luke,
Historically a user with ‘manage_network_users’ capability is a superadmin for the User Role Editor under WordPress multisite. I see that in rare cases as yours it should be changed and I will do it with one of the next update.
Workaround – take a code below, insert it into the separate .php file and place that file into wp-content/mu-plugins/ folder:
<?php add_action('plugins_loaded', 'remove_ure_from_network_menu'); function remove_ure_from_network_menu() { if (current_user_can('manage_network_plugins')) { return; } remove_action('network_admin_menu', array($GLOBALS['user_role_editor'], 'network_plugin_menu')); }
14/06/2016 at 16:24 #2417prolificParticipantVladimir,
I really appreciate your quick and thorough response! However, I tried the above code and it did not seem to work. I tried to make a few adjustments, but was unable to get it to work and don’t really have time to debug it myself.
Please let me know if you have any thoughts on why it might not be working. I look forward to your update!
14/06/2016 at 16:53 #2418VladimirKeymasterLuke,
I suppose that you installed it correctly as a must-use WP plugin.
PHP file should be readable/executable by your web server. It’s content should start from <?php tag. Check if user does not have a ‘manage_network_plugins’ capability.I tested exactly this code at my test WordPress multisite, where it works as expected – URE menu items does not appear under WP Network Admin.
Other workaround – you may replace ‘manage_network_users’ at line #239 of includes/classes/ure-lib.php to some other critical network capability, like ‘manage_network_plugins’.
-
AuthorPosts
- You must be logged in to reply to this topic.