Skip to main content
14 events
when toggle format what by license comment
Aug 10, 2012 at 13:06 comment added kaiser No, that's absolutely ok and what I understood the whole time. Just replace SET_CUSTOM_CAP_HERE with WIDGETS_MANAGER. Than assign this role to someone and give it a try - it works (I tested).
Aug 10, 2012 at 7:02 comment added Justas Butkus I create a new role Widgets Manager. It can manage only widgets (access wp-admin/widgets.php). I do not want to grant edit_themes_options cap to that role/user. I wish to create a new cap. User/role with that cap can access only widgets, not any other theme options menu item (there must be nothing under "Appearance" menu - it shall link to wp-admin/widgets.php directly). Maybe I have missed to express that previously - hope it is possible to see what I am after now.
Aug 9, 2012 at 12:37 history edited kaiser CC BY-SA 3.0
deleted 4 characters in body
Aug 9, 2012 at 12:06 comment added kaiser Ok, it seems that I simply don't get what you're after. What exact roles do you want to grant access? Subscribers, Contributers? (They'd need the parent menu entry too)... Do you want to add a custom cap or not? Do you want to give no one the edit_themes_options cap, avoid adding a new one, but still let some roles access the widgets page (at least that is what I understood now)?
Aug 9, 2012 at 10:50 comment added Justas Butkus maybe we are discussing different points. I am not talking about ADDING a new capability, without which users would be unable to see menu entry. Create a new user with Subscriber privileges. Then check if he can access wp-widgets.php (he should NOT). Then use your plugin to grant him SET_CUSTOM_CAP_HERE and check again - if you can access wp-widgets.php. Please make sure, that user was not granted edit_theme_options capability. For me, given clean (I actually downloaded fresh WP and installed in clean DB) installation - user does not get access.
Aug 7, 2012 at 15:34 history edited kaiser CC BY-SA 3.0
added 10 characters in body
Aug 7, 2012 at 14:41 history edited kaiser CC BY-SA 3.0
added 357 characters in body; deleted 77 characters in body
Aug 7, 2012 at 14:39 comment added kaiser @JustasButkus Yes, I tested it - else I wouldn't have said so. For me, it's enough to only the function restricting the menu. This prompts me with what you can see in the screenshot. If I remove the admin menu function from the MU-Plugin, I get the "Cheatin' uh?"-message. If I remove the capability nothing changes. Please deactivate all your plugins, switch back to the default TwentyEleven theme and try again. This is a problem with your setup (or some left overs in the DB/userWordPress Development Meta table) and not with my plugin. I also added this info as edit and linked a plugin that will help u.
Aug 7, 2012 at 14:34 history edited kaiser CC BY-SA 3.0
added 106 characters in body
Aug 7, 2012 at 14:27 comment added Justas Butkus thank you very much for the help, although have you actually tested, that given user, who does not have edit_theme_options permission could still access widgets configuration (wp-admin/widgets.php)? Because I have tested it (wp_get_current_user()->remove_cap('edit_theme_options')) and given the code above - I could not access widgets configuration, as I get the above mentioned error (stands for a reason).
Aug 7, 2012 at 13:13 comment added kaiser @JustasButkus No problem. In theory it would've been enough to change the permission of the custom cap (have you tried it, or are you just assuming it doesn't work? My test showed it working...). But anyway, I give you another update with a full plugin that does a second check inside the widgets.php page and aborts. Up voting appreciated.
Aug 7, 2012 at 13:11 history edited kaiser CC BY-SA 3.0
added 1386 characters in body; added 24 characters in body
Aug 7, 2012 at 6:24 comment added Justas Butkus thank you for the lengthy comment (haven't seen that trac issue), but this does not work due to the reason I have explained: in [this][core.svn.wordpress.org/trunk/wp-admin/widgets.php] file there is a check if ( ! current_user_can('edit_theme_options') ), thus any other permission fails. But yes, it works in menu items, nevertheless.
Aug 6, 2012 at 17:14 history answered kaiser CC BY-SA 3.0