@abland @boywondr16
At this point I would recommend installing User Role Manager plugin so that you check the specific roles and capabilities assigned to your user. Possibly additional capabilities have not been assigned to the user when the role was assigned for some reason, and this should allow you to add those if they are missing for some reason.
https://ww.wp.xz.cn/plugins/user-role-editor/
-
This reply was modified 6 years, 1 month ago by
Tony Hayes.
-
This reply was modified 6 years, 1 month ago by
Tony Hayes.
Thread Starter
Abland
(@abland)
Hi, Tony, @majick
My interim solution was to create a new user with Show Editor permissions for any edits.
I haven’t had time to delve into the code but I believe the issue resides in the rescind permissions based on roles in your plugin functions. Calling roles will not find a superadmin because it’s not really a role, so then the new capabilities are rescinded.
Use capabilities instead where current_user_can when checking who does or does not have permissions, then rescind those who don’t.
@abland Okay, I think the fact that the new Show Editor role works points supports the conclusion that new capabilities are not being added to user who already have capabilities assigned from existing roles (such as admininstrator) on your site. So when you have time I would suggest using the role editor to double check whether the users have the assigned capabilities.
If this turns out to be the problem, I might be able to add some kind of in-built tool feature to reset the plugin capabilities for a particular user if this happens again in the future. Unfortunately it’s not a good idea to automate this capability assignment -if someone has already adjusted their user capabilities they could be over-written.
(PS. If I recall correctly, as you say in multisite super-admins are stored separately, I’m pretty sure this means you can’t be a super-admin logged in without having a standard administrator user role on that site.)
@abland You could be still be right about the edit revocation code, if you want to test this further you could would removing the editing revocation capability filter:
<?php remove_filter( 'user_has_cap', 'radio_station_revoke_show_edit_cap', 10, 3 );
(Place this in a .php file in /wp-content/mu-plugins/ or in your child theme functions,)
If that does bypass the issue then I will know that is the source of the problem after all and can re-visit the logic that is going on there.
Thread Starter
Abland
(@abland)
Hi, Tony @majick
I tried that filter in the theme’s functions.php and it didn’t work. I also tried removing the revocation code itself and it didn’t work either.
I created a standalone admin user and they COULD edit and add schedules.
I installed User Role Editor and confirmed my profile DID have all the capabilities, however I could not see my capabilities as super admin, only admin. My thought is my superadmin status takes precedence over my admin status, and my superadmin status does not have the new capabilities.
I found the following article and wanted to experiment when I had time:
https://wordpress.stackexchange.com/questions/81907/adding-capabilities-to-super-admins
@abland I’m adding a bypass for superadmins on the edit revocations to the next version in case that helps.
But I’m not sure it if will make any difference. As noted in one of the answers in that link, by default superadmin has all capabilities.
I’m till not sure if/how a superadmin can not have an administrator role.
Thread Starter
Abland
(@abland)
@majick I just tried adding a new administrator user, and they could add and edit schedules. Then I granted them superadmin status and they could no longer add or edit.
I was trying to see if new superadmins were receiving the privileges versus existing, but none are receiving them.
I also tried the new superadmin user on a site where they were NOT an administrator. They still could not add or edit schedules.
So far:
A superadmin who is also an administrator on a site cannot add or edit schedules even though User Role Editor shows they have the permissions as an administrator.
A superadmin who is NOT an administrator on a site cannot add or edit schedules.
An administrator who used to be a superadmin CAN add or edit schedules.
The plugin does not appear to recognize Superadmins.
@abland I tested adding a simple permission bypass for super-admins, but this created an endless loop causing the plugin to crash. So it wasn’t included in 2.3.1
I am not sure on the process of how a user can become a super-admin on a site without being given the administrator role and how often this would happen. I’ve added this issue to Github as I might be able to find another solution in the future:
https://github.com/netmix/radio-station/issues/213