Posted: December 2, 2017 at 1:09 am
|
I posted a question about this about a month ago, but I realize that I did not specify that the user must be logged in before registering for an event. I think the solution provided by Tony can be used if the “auto-create” user option is enabled only. So for all my events the user need to be logged in before they can register. Ideally I would like to add different CCAP for different events also, but can manage with just one if that’s easier. |
|
update: can you “map” EE category to CCAP? It would make it more “sensible” for non-tech users. So whenever an event has a category assigned it will create this CCAP for the user registered for an event |
|
Found this post that describes exactly what I would like to achieve, but it’s from 2012 and there is no “solution” to this thread (not from what I can see). Is there another easier method of doing this or is the Pro API for remote operations a preferred route (modify_user (updates existing Users/Members) and “”s2member_ccaps” =>” |
|
sorry here’s the link: https://eventespresso.com/topic/bridging-s2member-and-event-espresso/ |
I don’t think you need the Pro API for remote operations for this, you can do it locally on the site. There is another hook fired in the WP user integration add-on when a user account is updated and not just when created:
(Only runs for the primary registrant) So then, as you have the WP_User object you can use the examples here: https://s2member.com/kb-article/rolescapabilities-via-php/
Yes, you can with the above. You have the registration object in
Then pull the terms for that event:
That obviously only pulls the ‘first’ category set on the event but you can pull them all using Is that what you are looking for? |
|
|
Spot on Tony! That’s exactly what I’m looking for! |
You don’t need a cron job, hook your code into the action I mentioned above and that code will run each time a logged in user registers. Have you used hooks (actions/filters) before? The code examples I’m referring to is how to add caps/ccaps to the user, the cron jobs are for something else. So looking here: https://s2member.com/kb-article/rolescapabilities-via-php#toc-207845e1 Shows how you can add the caps with the WP User object. |
|
|
My knowledge is limited to adding code snippets to my child-themes functions.php. Also I have added a site-specific plugin to add a remaining tickets column to the ticket selector in Event Espresso 4. |
Whilst I’m happy to help point you in the right direction, it’s important to note that we don’t support customizations so you may need the help of a developer. Take a look at this function: https://gist.github.com/Pebblo/47ee6301aa5767066074b4a450309bb7 That uses the hook I mentioned before, pulls all of the categories assigned to an event and adds them as capabilities to the current users account using the format ‘access_s2member_ccap_{category_slug}’ which I think is what you are looking for. |
|
|
Fantastic Tony, you are the best! Your example works as advertised and you totally saved my day. Next time I’m in Scouserland too watch a game with my favourite football team I’ll buy you a beer 🙂 |
The support post ‘create s2member ccap upon registration (not using autocreate)’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.