Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
How to force forum to update user permissions when changing WordPress role?
Avatar
tonya_lunarwp
Two Rivers, WI
Member
Free Members
sp_UserOfflineSmall Offline
Jan 22, 2015 - 2:04 pm

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?

Bringing ideas to life is my art
Web Developer · Software & Electrical Engineer · WordPress · Genesis

Find me: tonyadoescode.com | LUNARWP | Twitter

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 22, 2015 - 3:38 pm

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?

andy-signature.png
YELLOW
SWORDFISH
Avatar
tonya_lunarwp
Two Rivers, WI
Member
Free Members
sp_UserOfflineSmall Offline
Jan 22, 2015 - 3:50 pm

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?

Bringing ideas to life is my art
Web Developer · Software & Electrical Engineer · WordPress · Genesis

Find me: tonyadoescode.com | LUNARWP | Twitter

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 22, 2015 - 4:02 pm

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
tonya_lunarwp
Two Rivers, WI
Member
Free Members
sp_UserOfflineSmall Offline
Jan 22, 2015 - 4:03 pm

Perfect.  Thank you for your help.

Bringing ideas to life is my art
Web Developer · Software & Electrical Engineer · WordPress · Genesis

Find me: tonyadoescode.com | LUNARWP | Twitter

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 22, 2015 - 4:15 pm

Ask away if you get stuck!

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 616
Members: 17344
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10117
Posts: 79600