Change WordPress user roles and capabilities › Forums › Bug Reports › Administrator Menu Access module and custom posts (editing)
- This topic has 4 replies, 2 voices, and was last updated 6 years, 1 month ago by dhokeefe.
15/02/2017 at 11:03 #3365
I have turned on “Administrator Menu Access module” and it is causing problems with editing custom posts.
– I have custom post type “company_latest_news”
– I update a role under “Admin Menu” – select “Block menu items ‘Not Selected'” and select my Company Latest News (edit.php?post_type=company_latest_news)
– when I login with that role. Everything is good except when I click to edit the custom post it redirects back to the dashboaard (if I am allowing that) or to the page “/edit.php?post_type=company_latest_news”
– So for example I click on one of my custom posts and it wants to go to this page “localhost/wp-admin/post.php?post=85&action=edit” but redirects back.
– If i turn off “Activate Administrator Menu Access module” everything works fine but obviously the admin menu is not restricted at all
Am I missing how I should be setting this up? I know I can use “Block menu items selected” but that seems to hide them but not actually restrict access, also if I have multiple roles the rules overwrite each other and no menu items are visible at all.
Essentially I am trying to create a set of roles – each one granting access to a specific menu item and multiple roles can be selected when creating a user to give access to each section. All sections comprise custom post types.
Any help or guidance would be very much appreciated!
Donal16/02/2017 at 10:42 #3367VladimirKeymaster
When you select a menu item to be blocked, URE does not simply hides it. URE blocks the URL assigned to the hidden menu item. Any try to use blocked URL leads to the redirection to URL, assigned to the 1st available (not blocked) menu item.
When we work with ‘block not selected’ model – all URLs from the main admin menu except apparently selected become blocked. So I suppose that you have some menu item with similar URL, like ‘wp-admin/post.php?post=nn&action=edit’ and it’s counted as blocked.
I can not repeat described situation at my development environment though, as I don’t have supposed menu item.
All selected URLs under “block selected’ model should be really blocked. Can you show an example when you turn ON some checkbox but still can access that URL typing it directly at a browser address bar?
Combining “Admin menu access” data from multiple roles assigned to the same user, you have to take into account this logic:
– assigned restrictions take effect in the assigned roles order. Admin menu blocking data from the 1st (primary) role takes effect always;
– data from the rest roles are taking into account only if they use the same blocking model. For example, if the 1st role has ‘block selected’ model, but the 2nd role has ‘block not selected’ model, the 2nd role ‘admin menu access’ data is ignored.
– ‘admin menu access’ data from other roles with the same blocking model are added to the data from the 1st role.
If you have an example when the rules described above don’t work, let’s discuss it. I will try to repeat the situation and fix the bug if we discover it.16/02/2017 at 23:37 #3370
Thanks Vladimir for the details,
The notes on how the order of assigned roles affects the access probably explains some of the results I have had.
If I understand correctly though. I can’t use “Block Not Selected” if I’m working with custom post types – as these are always edited with a URL similar to “wp-admin/post.php?post=nn&action=edit’. Is that correct?17/02/2017 at 01:44 #3371VladimirKeymaster
I can’t use “Block Not Selected” if I’m working with custom post types – as these are always edited with a URL similar to “wp-admin/post.php?post=nn&action=edit’. Is that correct?
No, in general, it’s possible to use “block not selected” option with custom post types. I suppose, that a possible source of a problem in your case is that the link like ‘wp-admin/post.php?post=nn&action=edit’ would be associated with one of the existed (but not selected and thus blocked) admin menu item, created by a theme or plugin. URE does not block any link except selected, just not selected links included into admin menu should be blocked.
Try to look for similar URL at the list of URLs shown at the dialog window when you click ‘Admin menu’ for the role. Is there such URL? To what plugin does it belong?17/02/2017 at 02:40 #3372
This makes sense – thanks so much for your feedback and help.
- You must be logged in to reply to this topic.