Support Forum

How to force forum to update user permissions when changing WordPress role?

TL tonya_lunarwp
tonya_lunarwp
Member

On our site, we change the user’s role based upon their activity (upgrade, withdraw, etc.).  When we initiate to change the WordPress user role, we also want to force the forum to re-evaluate the user’s new role and then adjust the permissions and memberships appropriately.

What functions, actions, or filters do we call?

5 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Forum admin > Manage User Groups > Map Users to User Groups.

Here you can set up relationships between WP Roles and SP User Groups.

As long as whatever changes the WP role for a user uses the proper WP API to do so then this will also re-assign a user from an old user group to a new one based upon the mapped relationships. This works best, of course, if the option to limit a user membership to one user group at a time is set on.

Is this what you are looking for?

TL tonya_lunarwp
tonya_lunarwp
Member

Actually we are a multisite for our intranet.  We change users roles on a staff site that does not have the forum loaded.  When this occurs, it loops through each of the sites and changes them appropriately.  As the forum is not installed on this site, ‘sp_map_role_to_ug’ is not called.

What I need to do is programmatically load the right files and then call the right function.  I’m assuming I need to call ‘sp_map_role_to_ug’.  Is this correct?

YS Yellow Swordfish
Yellow Swordfish
Member

That is the right function indeed. So is your plan to basically replicate that logic on the ‘staff site’ which would seem to be the easiest way. It’s all pretty straightforward.