Posted: April 28, 2020 at 8:01 am
Dear EE-support team,
we are currently implementing a custom plugin to be able to do further actions / custom functions with the data provided by our EE instalment. If a user opens an event, we want to check with his user_id to see if he’s already signed up on that event. If he is, then we will change the “enrol / sign up” button to a “cancel enrolment / sign off” button with further functionality (user will be able to cancel his enrolment). But there are also other functions planned that would need a list of the user’s enrolled events and then “do something else with that”. 😉
The problem that we seem to have (please feel free to correct me as we are no php professionals like you are) is, that when we use filters and hooks (like the filter for changing the button’s name), we’re not able to parse more data to other custom functions in our custom plugin.
Maybe we’re just missing something as will still learn Event Espresso and custom code for wordpress, but does EE provide some way to get that data described? In advance, thank you very much for any help, hint or trick! 🙂
Depending on your setup, you may not be able to just use the user_id for the current user. For example, if you don’t sync up the registration form with the current wp user, then not all of the registrations will be linked to the current users EE contact and the above wont work.
If you allow group registrations, the additional group registrations not using the primary registrants EE contact, would not be linked to the current user.
In short there is a fair bit to getting the above done.
I’m not really sure what you are asking here.
If you are asking if you can call other functions within a callback function on a hook within EE, then yes you can.
Do you have an example?
We (EE staff) normally prefix functions with our initials, so
Why can you not access
It depends on what has been passed to the hook you are using if you have an object available, if not you would need to manually pull the details in yourself using our model system.
It sounds like you could do with reading over the documentation on our model system, available here:
You can pull any info from within EE using those models.
Whilst we don’t have an example of what you requested in your initial question, I do have a snippet that adds another action to the My Events output that allows the user to cancel their registration, would that help?
Note the snippet is unsupported and should be considered untested, so confirm it does everything you need before pushing it live: