Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
How to catch the add_role action
Avatar
Samantha
Member
sp_UserOfflineSmall Offline
Nov 9, 2014 - 9:41 pm

Hi -

I'm using MemberPress with my site, and I have multiple course products that a user can purchase.  I am running into trouble because SimplePress is not picking up the "add_role" action that we are using to add multiple roles for a user.  I've read the other post that recently had a similar issue, and I used the Event Logger to confirm that SimplePress doesn't appear to catch the "add_role" action.

Is it possible to address this?  Otherwise, my students are not going to have access to their course forums.

Thanks!
Samantha

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 9, 2014 - 10:53 pm

not sure what you mean by the 'add_role' action...  wp does not have such an action...

when wp changes the role of a user, it fires the 'set_user_role' action...  This is to let themes and plugins know that a user's role has changed...  if a role is being changed in a non standard manner, then plugins wont know about it..

if you are changing the role independently of the wp api, you could fire the same action and things should work...  the action should be fired (as wp does) with three arguments... the first is the user id (integer), the second is the new role (string) and the third argument is the old roles (array)...

of course, its possible there is an implementation of wp role changing that has changed in wp or a path we are not aware of, but the role changing seems to be working for  users...

Avatar
Samantha
Member
sp_UserOfflineSmall Offline
Nov 10, 2014 - 12:04 am

Hi -

Thanks for the reply.  Is there an add_user_role action?

I've got a message in to the MemberPress team to see if there's anything they can do on their end to help resolve this.  I'll post again if I have something concrete to ask.

Thx!
Samantha

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 10, 2014 - 3:46 am

I can find no mention of an 'add_user_role' action hook in the WordPress core code. We have, sadly, come across a few plugins over the years that replace a part of core functionality but do not implement the standard hooks. Actually, I believe we were guilty of this on at least one occasion many years ago!

Please do let us know what the membership people come back with. If they can provide a custom hook that IS available that passes the same data then we can probably help you implement that

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 10, 2014 - 10:04 pm

I only know of the action I mentioned previously...  where are you getting these actions from?  docs?  or hooks that your membership plugin is firing?

Avatar
Samantha
Member
sp_UserOfflineSmall Offline
Nov 11, 2014 - 10:31 am

Hi -

The MemberPress guys came back and said the add_role is a supported action/problem-with-post-edit-buttonook in the WordPress codex.  Here's a link:

 

http://codex.wordpress.org/Cla.....24role_.29

 

Is there any way to get support for this action into SimplePress?  It would allow my new users to once again have their Forum access set automatically, instead of me having to go in and update it for each new user.

 

Thanks!

Samantha

Avatar
Samantha
Member
sp_UserOfflineSmall Offline
Nov 11, 2014 - 10:33 am

In case you prefer the Code Reference, I also found it there:

https://developer.wordpress.or...../add_role/

 

Thx!

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 11, 2014 - 11:22 am

I will look into this tonight... and come back to you.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 11, 2014 - 11:55 am

'add_role' is a core function NOT an action hook. No plugins can extract any information from a function such as this.

I was also under the impression that it was your users that we needed to know about which is not the same thing as a role.

As Mr Papa said above - the standard WordPress action hook for adding a user to a role is the 'set_user_role’ action…

andy-signature.png
YELLOW
SWORDFISH
Avatar
Samantha
Member
sp_UserOfflineSmall Offline
Nov 11, 2014 - 1:39 pm

Hi again,

I'm setting Forum permissions based on user roles, and some users may have multiple roles.  For existing users, MemberPress is using "add_role" to add the additional roles for each user.  

They are telling me the exact opposite of what you're saying - they tell me that lots of plug-ins catch the add_role and are able to use that to set up additional info.

I'll go back to them again with your comments above, and see what they say.

Thanks!

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: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625