Support Forum
interesting... it does seem possible to ADD a wp role to a user via the add_role function... however, it may or may not have any impact on the user capabilities, since a level check is done...
additionally, the user will now have multiple wp roles which could be construed as problematic since multiple wp roles may map to multiple sp usergroups... from a wp perspective you will just get the higher level of the two roles... but still have both levels...
there is a corresponding remove role function which can remove a specific level...
however, neither the add role function or the remove role function have applicable hooks fired by wp that lets other plugins know that roles were changing (which is probably why core uses set role)... the set role replaces the current role with the new role such that the user maintains single wp role...
there is a level change hook that might could be tied into, but its potentially problematic in that a single level can belong to multiple roles... so from the level hook, I am not sure we can know which role was added (or removed)...
so, will have to do more research, but at this point, adding a role, vice setting the role, may not tell plugins about the role change... and a user may end up with two roles which would cause an issue when mapping roles to user groups...
Visit Cruise Talk Central and Mr Papa's World
Hi -
I am reopening this thread because the fix I thought I had is not actually working.
I was able to get the MemberPress guys to modify the plug-in they provided so that it would call the set_user_role action, per your previous replies. However, when I added a course to an existing site and forum user, the user's Forum roles were not updated to reflect the new permissions. I can see in the Event Logger that the set_user_role was triggered (see attached screenshot), but the user's permissions were not updated (see second screenshot).
I am opening a new course for registration, and would really like to understand what is happening here, so I don't have to manually add permissions for every student.
I don't know if this is relevant or not, since I can see the set_user_role action in the SP event logger, but this is how the set roles action is being called:
do_action('set_user_role', $user->ID, 'participant_ur_jan2015', $old_roles);
//Doesn't actually change user's role -- just fires this hook for Simple Press' sake
Thx,
Samantha
1 Guest(s)