Posted: November 20, 2019 at 3:19 am
|
I implemented some code on a client’s site. But this code isn’t returning some events. I checked whether the event status has something to do with it. But it doesn’t seem like it. Some events like http://www.pia.org.za/events/professional-practice-programme-session-5/ just doesn’t show up, even though there are registrations (and check-ins) for that event, The code:
|
Hi there, Your not pulling events, your pulling registrations and then using the registration to get the event, so if an event isn’t showing its more likely to be something with the registration than the event with your code. Have you confirmed that the A registration will only be linked to a contact if their first name, last name and email address match the contact exactly, so the missing registrations may well be linked to another contact. If you view the registration list within EE and then hover over the contact icon (this) you’ll see a Does that ID number match the |
|
|
Okay, so I see that this indeed doesn’t match. And I also see in the source that you can’t get this from any other field, ie. email. I think this is affecting quite a few registrations, and I have no way of quantifying which of the registrations were affected. Any way to revert the id to the users’ old id? Or any advice that you can give me to connect the data again? |
Sure you can. You can use our models to pass EE_Attendee the email address to pull all contacts using that email, example:
That will return an array of EE_Contacts in the system that has the email address passed. You can also pull all of the registrations linked to any contact with a specific email address:
Now I can’t say this will work for all use cases but if you are looking for all of the registrations made with the user’s current email address you can use the above. EE does not have a method to pull every registration created by a user if they have use different attendee details on those registrations.
Just to clarify, affected in what way? Every registration that has different attendee details will have its own contact for that attendee data. If you change the att_id you change the attendee (Note this is different from the wp user) that registration is linked to, meaning the registration will show that ‘new’ users details as it is not just a ‘link to the user that created the registration. So to be clear, if you change the att_id on a registration to something else, you’ll update the details shown for that registration to whatever contact details that new ID has. This isn’t the WP User details, it’s the EE Contact details which you can see in Event Espresso -> Registrations -> Contact list. |
|
|
Thank you very much for this. I will implement this and see if it is a better fit for our system. Just to clarify, maybe affected wasn’t the best word choice. But rather, I can’t really quantify which registrations took place, but aren’t showing on the users profile due to a mismatch in ids. |
If you haven’t done so already I highly recommend taking a look over the docs for our model’s system: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System There’s a lot of info you can pull through the models fairly easily.
Ah, ok, yeah I understand. EE doesn’t store the ID of the user that made a registration with that registration, so there’s currently no way to pull all registrations made by a specific user. |
|
|
Thank you, sorry for only replying now. This works fine. I am going to do a combination of the two, both id and email. Because what happens is the admins register for the users sometimes from the backend, and i suspect that this is why the contacts are changed. However, when I run the code above, it is giving me an error on the date for the event, relating to the start_date function on line 34. Apparently the object for get_related_primary_datetime() is null, the specific error: |
No, you don’t need an instance
So use something like:
The above 2 methods order the datetimes related to the ticket on a registration based on the DTT_EVT_start value. |
|
|
Thank you for your help. However, when I implement this, I get the name of the event, and the id in brackets? Even if I add it within the instanceof conditional. Does the function normally return the title? |
The code I gave you above doesn’t return/output anything so it will depend on what you’ve done with it. The Can you post the code you are now using to something like http://wpbin.io/ and add the link here for us to view? |
|
|
Sure, apologies for the messy code, this is still on a development server while I sort out the event list. With this I just hook into the buddypress after profile hook and echo the shortcode that I create to display the event list there. For the reference by ID section (the top code), I used the deprecated function, which still works correctly. Then I just append the new get via email section. The javascript function at the end just hides duplicate entries for the admin who registeres lot of users from the backend. |
Ok, so the problem is your using objects as strings and your also confusing ‘Datetime objects’ with dates and times. For example:
Using
You will not get what you are expecting, which is what I assume you mean with this:
You are not getting the event name and ID there, you are getting the Datetime Name and ID but even then, this isn’t how you use objects and its only working because PHP is converting the object to a string for you, but then you have no control over what you output. In the above example Right now I can tell that changing Similar code stands out in other locations, such as
Further on you have:
Because I highly recommend you read over the Model system documentation I linked to above, this: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System You are running into multiple problems simply because your not using PHP objects correctly and you’re going to run into more of them until you understand what |
|
The support post ‘Some events not displaying when using get_all_registrations_for_attendee’ 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.