Posted: May 2, 2022 at 2:47 am
Hi there team, I hope you guys are doing well! As there is no addons currently available for this, I am trying to create a way for me to credit user accounts with gamification points based on the final amount paid with a certain scale ($1 = 100 points). The gamification system (myCred) has an API layer to credit the points and deduct points but I am unsure of which function/action/filter/endpoint that I can use for this scenario. My apologies for the lack of understanding of the REST API on my end; I hope you guys can point me in the right direction. Thank you! |
|
Hi there, If you are running the function on the site that EE runs on, you don’t need to use the EE REST API for this and can hook in to send a request to myCred from there. With regards to payments made within Event Espresso, how are you expecting this to work? Do you only want to credit myCred when the total amount is paid in full, meaning the EE Transaction status switches to ‘complete’ and the registration status switches to ‘Approved’? |
|
Hi Tony! Great to hear from you, thank you for your reply. I want to credit myCred when the registration status switches to ‘approved’ and deduct points when it switches to ‘cancelled’ Thank you! |
|
Ok, so you have a couple of options and the way I would start is to look into this hook:
That is ‘fired’ whenever a registration’s status is changed to approved. After that you can look into:
Which is fired whenever a registration’s status is change FROM approved to something else, the Does that help? |
|
Hi Tony, That was a really great start for me, I’ve been experimenting but to no avail and I will have to trouble you again. Using your example of status to approved,
-May I know where do I add my code for the API Thanks! |
|
I assume you are aware of how to use WordPress hooks? https://www.smashingmagazine.com/2011/10/definitive-guide-wordpress-hooks/ Add your function to the above action.
Ok, my recommendation is to take a read of our model system documentation: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System It allows you to relatively easily pull in all of the information you might need once you get used to it. Combine that with Kint: https://wordpress.org/plugins/kint-debugger/ Wrap your objects in |
|
The support post ‘REST API Payment amount credit/deduct points’ 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.