Posted: June 28, 2019 at 9:45 am
Greetings – When we setup events in EE for training we also setup multiple dates and times for the training using the “Event Datetimes” section. SO the user goes to the event page, chooses the datetime of interest, and proceeds to the registration page. Then they fill out the registration page fields and select the Submit button. In the back-end PHP the registration field data shows up in the $data object, but not any of the “Event Datetime” or event ticket information (name, desc, etc.) – so I can’t tell what specific datetime was chosen for the event. I need to get at this data somehow. Can you help me out? Here is what is in the $data object upon the Submit: [28-Jun-2019 14:52:21 UTC] $data Array [1-9b2d0cc33250a445bb98613a6816e0cc] => Array ) |
|
If you want to see this in action go here: |
|
Hi, I’m not sure where/how you’re getting the $data object. It looks like it could be the registration form object, which does not include ticket or datetime data. What you could do is start with the EE_Checkout object and from there get the EE_Registration object, which can access the EE_Ticket object, which can access the EE_Datetime objects. e.g.
|
|
Josh – Yes, the $data is the registration form object. Thanks for working up the sample code – MUCH appreciated. One more question: If I wanted to access say the first name element in $data how do I do this? I’ve tried these and they don’t work… $firstname = $data[fname]; Thanks again! |
|
I’m not sure. May I ask how exactly are you getting the $data object? |
|
Sure – A while back you showed me that I could extend the Submit registration functionality by tying into an AHEE action like this:
So the $data object looks like the registration form object based on what is inside of it. Printing that $data object is what I listed at the top of this post – it’s an ugly object. I’m not sure how to access the different data elements of it like “fname” and “lname” for example. Does this help?
|
|
Josh – Going back to your code example when I run it the $datetimes object contains an array of ALL the datetimes for that event. I only care about the datetime that was actually selected by the user. How can I determine that? Thanks so much for all of you help!!! |
|
It should only return datetimes for that specific ticket, it doesn’t query the event. Are you sure the ticket is assigned to only one datetime? |
|
On that hook
That’s not going to be the same on the next registration, meaning it’s not going work for what you need.
To step back from this a second, with EE users do NOT select datetimes, they select tickets (which are assigned to datetimes). I get that you are naming your ticket the same as the datetime etc, but its an important distinction, because:
They didn’t select a datetime, they selected a ticket, yes it’s linked to a datetime but they selected a ticket and it’s the ticket you need to work with to get back to the datetime. Can you pull the datetime(s) the ticket they selected from their ticket/registration? Sure you can and the code Josh gave you above should do just that BUT tickets can also be assigned to multiple datetimes which may cause problems. So, starting from the beginning for what you want to do, have you confirmed that the ticket the user selected above is assigned to ONLY one specific DateTime? Was it on the event you included above? If so, which specific ticket did they select on that? We can investigate a little more from there. |
|
THANK YOU for the information above – that was helpful. I did have a few tickets that had multiple Datetimes assigned to them – my bad, sorry. I am now simplifying this: I am just going to work with the tickets. So to each TICKET for an event I am adding to the ticket description a meeting number, e.g. 123-456-789. So using Josh’s code I can get the TICKET that was selected. So $ticket is an EE_Ticket object. I want to get the description for that ticket. How do I get that? I thought it would be something like $ticket.description() but I get a “PHP Fatal error: Uncaught Error: Call to undefined function description()” when I do that. The EE_Ticket class has that function defined as public: *************** Thanks guys! – Mark |
|
Nevermind – I figured that one out. It is $ticket->description(). (I am still learning PHP nuances, coming from a deep Java background 🙂 This issue can be closed now. |
|
Should be |
|
I spoke too soon -> I checked the EE_Checkout object, the EE_Transaction object, the EE_Registration object, and the EE_Ticket object and none of them contain the form input from the Registration page. Only the $data object that is a parameter in my called function below contains it. But this is a very confusing object to me – I can’t figure out how to get the individual form input elements like “fname” “lname” “email” etc. The $data object contents are listed at the very top of this posting. How can I get at the individual form elements using PHP code? function my_custom_submit_action( $spco, $data) // $data has the form input Thanks – Mark |
|
Forget about There’s a huge number of hooks in EE (~900 action hook, frefixed with
Check its an instanceof
Please take a look over the model documentation as it goes through all of this: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System |
|
Tony – I will look that over shortly. Quick question: My registration page has several custom fields of input as well as the normal default fields. Will the custom field input also be available somewhere in the EE_Attendee object? That’s why I thought I had to use the $data object, because it contains everything. Mark |
|
The answers to custom questions are available from EE_Answer, which is related to the EE_Registration object. There are methods that can be used too. e.g. all answers:
or for an answer to a specific question with ID 20:
|
|
The support post ‘EE4: Not seeing any "Event Datetimes" or event ticket info in the $data object’ 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.