-
Notifications
You must be signed in to change notification settings - Fork 23
Fix for role-assignment problem... :-) #58
Description
There is a problem with the role assignment:
If $amp_default_role is set, all logged in users are assigned to this default_role,
no matter if there is an entry for the user in the $amp_role_assignment-array.
As stated in the previous published issues this seems not to be a consistent behaviour.
I tried to get down to the problem and found a solution.
Change the following lines in plugin.php: 271-278 in the following way:
if ( amp_user_is_assigned ( $user ) )
{
foreach ( $amp_role_capabilities as $rolename => $rolecaps )
{
if ( amp_user_has_role( $user, $rolename ) ){
$user_caps = array_merge( $user_caps, $rolecaps );
}
}
}
elseif ( isset( $amp_default_role ) &&
in_array ($amp_default_role, array_keys( $amp_role_capabilities ) ))
{
$user_caps = $amp_role_capabilities [ $amp_default_role ];
}
The introduced brackets are imminent important!
The bracket in the line before the elseif makes the difference!
It assigns the elseif to the if-statement in line 271!
Without the bracket it depends on the version of your php interpreter how the elseif is assigned...
Some php interpreters (I presume the older ones) handle this assignment as described above...
Others (newer ones perhaps) seem to loose track and handle the elseif as a normal if-statement
without assignment due to missing brackets...
Regards