Posted: June 26, 2019 at 2:09 am
|
Hi, Two things: 1. We are trying to get todays events and then get the registrant data for each event i.e First/Last name and the custom registration fields. This needs to be custom so we are looking to use the classes which I have got a start with but want to see if there’s a better way as it isn’t finding the first and last names (probably using the wrong class). 2. We have custom meta fields on the user so wondering if there’s a hook we can use so upon registering (when the account is created) can we save the registration custom fields (etc) to the user account. Thanks in advance for your help. |
Hi there,
Can you post the code you currently have so we can take a look? We can’t write custom code for you but we can help point you in the right direction.
When registering onto an event and the account is created by EE you mean? If so then you’re using the WP User integration add-on to create/update the user accounts? If so take a look in: It has 2 hooks:
and
both are passed the user account and the current registration. |
|
|
Hi Tony, Thanks for this it is a great help. 1. The code is https://pastebin.com/VtJGg5tF if it helps we are trying to create a custom CSV export to break the export in to sections for each event to list the attendees to that event with the relevant data, they want it a bit more custom to just removing irrelevant fields screenshot here: http://prntscr.com/o6vcsr 2. That’s perfect looks like it will do the trick, when I get round to that part I will let you know how it goes. Thanks |
For #1 EE offers event specific registration exports already: Event Espresso -> Events -> {hover over event name} -> Registrations That lists all of the registrations for that specific event. All of the CSV fields are passed through a filter, meaning you can use that filter to add additional columns or remove columns. So in short, if all you are looking to do is create a CSV that looks like the above, you can do that using the I’m assuming based on your reply that you’ve already seen similar uses of that filter (or one similar) top remove/re-order the fileds but you can completely change the CSV output using that if needed. I’m guessing some of those fields are based on user meta rather than all from the registration form? |
|
|
Thanks Tony, the problem with it is they want to section out each event. So if you look at the screenshot the CSV will be like that but for each event on one csv printout with necessary headings. So it would be: Event Heading (etc) (spacing to get it to a new page) Event Heading (etc) (spacing to get it to a new page) etc.. Does that make sense can send full CSV if it would help? I was going to do it this way but because of the layout of the CSV I thought it might be worth doing it custom? Thanks |
Ah, right, ok that’s not really clear in the screenshot but I understand now. Have you done that before with a CSV? Some of what you have in the image can’t be saved in CSV, for example, the merged fields for the header, I don’t think you can save that in the field, the header sure, but not the formatting to merge the fields. What issue do you have with your current code? Right now you’re overwriting the save value in the $values array with the name of the attendee, so it will essentially also contain a single value and that the First Name of the last registration’s attendee. |
|
|
No can’t really use the styling but plain text in that format would be fine. I suppose I would do something like Event Name, Date Time & Instructor and just have it as one field/cell. It isn’t printing the fname as it says it doesn’t exist in the class? How would I get the custom registration fields from that also? Thanks |
What’s the exact error you are getting? I’m guessing You’ll need to either check you have a valid EE_Attendee object for each registration first, or exclude those registrations from the query which you can do with:
Add that to the where conditions for the EEM_Registrations call.
I’d recommend you take a look at how EE constructs the default registration csv rows in:
The code there will guide you through on how to pull all of the information you need. |
|
|
Thanks Tony I will take a look in the get_csv_data_for function I tried adding your code and got: Fatal error: Uncaught EE_Error: You passed Transaction.STS_ID as a query parameter to EEM_Registration, which is illegal! But If I re-work it with the get_csv_data_for function might have better luck. Thanks |
The above error means your not passing my code in the where conditions but as a query parameter. The above means you have something like this:
You need something like this:
|
|
|
Sounds about right thanks tony I will let you know how I get on. |
You’re most welcome. |
|
|
Hi Tony, Sorry another question, is there a way to show the amount of attendees on the checkout page i.e if they sign up to multiple attendees for an event or if they have 2 different events with 1 attendee for each? I have seen you can do it based on event but assume theres a different way to get this displayed on the checkout page? Thanks |
My apologies but I’m not sure I follow. In EE there’s a 1 to 1 relationship between tickets and registrations, each ticket creates a registration within EE and the checkout page shows a breakdown of all of your registrations already so I guess I don’t understand your question. Can you add a screenshot showing what it is you want to do? https://eventespresso.com/wiki/troubleshooting-checklist/#screenshots |
|
|
Sorry so on the checkout page I want to show the users attendees (saved as meta data) and then allow then to copy that data over to one of the attendee forms. If you look at the screenshot you will notice my drop down, I want to say copy attendee data to either Attendee 1 or 2 etc. Thanks |
|
Sorry dont worry Tony now I am looking at it, it was easy to find! $total_tickets = EE_Registry::instance()->CART->all_ticket_quantity_count(); |
|
Hi Tony, I have hit a little snag, we are using Multi event registrations so is there a possible way to add all attendee data to 1 user account? I think this hook ‘AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_created’ just allows it for the standard EE4 setup is that correct? Thanks, |
|
Hi Tony, OK so managed to look in to the CSV export more, looking at get_csv_data_for it looks like its what I need as I can just filter out the columns I don’t need for each event however I can’t seem to connect to the CLASS I am obviously missing something assuming I need to include the namespace of some sort? If not is there a quicker way than having to replicate what this function does would it be as easy as copying the function and changing where it references $this to the correct class? Thanks again and sorry for the questions! |
May I ask how that would work? If you have attendee 1 linked to profile one, what would you do with attendee 2’s details?
Can you define the ‘standard EE4 setup’ in this situation? That hook is fired when a user account is created, you can link the registration data from all registrations to that account using the same hook if needed so I’m not sure what you mean. The more context you can provide on what you’re trying to do at each step, the better/more specific we can be with our answers for your use case.
I’m not sure what you mean by ‘connect to the CLASS’? Do you mean how you use the class? It’s used as part of a batch process, so you’d also need your own batch method if you want to do it using the class as is if I’m not mistaken, but either way it’s not something we can walk you through on the forums.
Well, no not really, other than building out your own custom version from scratch. There is the |
|
|
Thanks Tony.
What I am trying to do is create 1 user account but save all the attendees data to my custom meta field (array). I think how the EE login plugin works is it create 1 account for the primary attendee?
I want to use the get_csv_data_for function, what is the best way to use it? I am trying to loop through each event and get the data for that event for example: foreach ($events as $event) I can then create my own CSV output like I shown you earlier in the thread. Thanks again for your help. |
lockquote>What I am trying to do is create 1 user account but save all the attendees data to my custom meta field (array). I think how the EE login plugin works is it create 1 account for the primary attendee?
If you have an EE_Registration object (which the above hooks does) you can call the
In that case, you would be better copying the function and editing the suit. |
|
|
Hi Tony, Ah perfect I wanted it to run on update too so assume it should be the same just use the AHEE__EED_WP_Users_SPCO__process_wpuser_for_attendee__user_user_updated hook? OK perfect I thought that might be the case and I should be able to use the classes within get_csv_data_for() function or am I better off creating a total custom query? Thanks |
Yeah, you can use both hooks.
Sure, you should be able to use the classes used within that method but I haven’t stepped through the code to confirm. |
|
|
OK I will try today, thanks again Tony for your great help. |
|
Hi Tony, So it turned out to be problematic so going to create my own batch job as probably the best way to use the event espresso classes etc. I have followed this and copied the RegistrationsReport (just for testing) but I can seem to find where I can put this code:
I have got it to print out on my custom admin page but it doesn’t like $this (obviously) I have got my custom batch and put it in /libraries/batch/JobHandlers/ do I have to declare the above in my custom file somewhere? Sorry to be a right pain! Thanks |
|
Sorry Tony, Ignore the above, I am sure there’s an easier way I can achieve this I think there has been some confusion on what I am trying to achieve. So I am trying to create a CSV as you know, these are the steps I am assuming I need to take: 1. Get all todays events Could you let me know which modals I may need and any examples of using them please as I think I am getting confused with the Attendees modal and the Registrations modal, sorry I am not familiar with the way EE works so it’s all new to me! Thanks again for your support |
I don’t think there is any confusion on what you’re trying to do, you essentially want an event registration report for multiple events in a single CSV (with separators etc), right? However, what you are trying to do is not as ‘easy’ as it seems. Is it massively complex? No. But it’s not something your just going to be able to plug in one of EE’s functions into and loop over without customization or following through with how EE batches work.
Have you checked the documentation on how the models work? https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System The functions I mentioned above already show you how to use the models to get all of the information you need, so if you don’t follow that then me giving you more examples isn’t really going to help if you don’t understand the model system. Also, without stepping through and essentially doing this for you to work out everything you need (which we can’t do as we don’t support custom development) I can’t give you more specifics. |
|
|
Hi Tony, Thanks for this, totally understand I will get my head around these Models then the get_csv_data looks like quite a lot of queries but I will see what I can do. Thanks |
|
Hi Tony, Your going to be sick of me soon, sorry! I am still getting the fname is null on my query although there is a contact assigned and I am getting the Attendee object also.
object(EE_Attendee) object shows if I var_dump $attendee so can’t see why it still thinks its null as I can see fname in the object. Thanks again… |
Are you sure the EE_Attendee object that you’re seeing above is in the same iteration of your loop? If you know you have an EE_Attendee object then you won’t be getting an error like:
On that iteration of the loop. What you can do is build out your
That will change your Get into the habit of checking you have an instance of something before you try to use one of its methods, it’ll prevent the fatal errors your getting, it doesn’t fix the problem (as the problem is the registration doesn’t have an attendee) but stops the fatal and allows you to trace it back from there. |
|
|
Thanks Tony, it wasn’t getting the attendees I was expecting seems 1 is missing the attendee class is there a better way to get the correct event datetime object I thought using REG_date but doesn’t seem to be getting the right attendees will look in to it again. |
Your not getting a DateTime object in the code above so I’m not sure? If you mean the code to pull registrations created between certain dates, ie:
then no, the above is the correct way to do it, although you’ll obviously want that to be more dynamic. However, that is different from your original request as that’s essentially pulling a daily request of registrations…. so you want registration made on the day of the event? Or to pul it in the context of that code, you want all of the registrations created between 2019-07-03 00:00:00 & 2019-07-03 23:59:59? Note registrations linked to events on that date, but registrations actually made/created between those times? If you want all of the registrations for a specific event, you don’t need to set |
|
|
Hi Tony, Your right that’s obviously not going to work, sorry a lot of late nights working on this! How would I get the correct registrations for the Event Date time? Can I use $event->datetimes and query the same dates as I do events? How do you query the registration object with date time? Sorry again for all my questions, thanks |
|
Just a breakdown of what I am doing: 1. Getting Events for today Thanks |
Within the registration row of the DB there is no DateTime ID (DTT_ID) specified as a registration is linked to a ticket and the ticket is linked to a datetime. So you need to pull the registration based on the info you have and link them together when you pass that to the model. So you have a Ticket, linked to a datetime and want the DTT_ID of the datetime, in other words you need to JOIN the datetime table to the registration table based on the ID of the datetime linked to the ticket, sounds tough, but the models make it easy, which is why I keep pointing you the models. In the where conditions for the EEM_Registration query you can add:
A little easier to read it backwards, in English ‘Where the DTT_ID of the DateTime linked to the Ticket for the registration (because it’s on the registration model) is…’ How you get the
Events don’t have dates set on them, they have datetimes assigned to them which have dates, so whatever you are doing to pull the events by date, is actually using the datetimes… so yes you can use the same dates. You can pull the datetimes from an event using the above method yes and We have an example here:
Isn’t this the same as your first question? If not my apologies, but if that’s the case I’ll need more info.
Can you define the ‘correct’ DateTime within an event? I’m assuming you don’t have a page displaying the registrations which can be filtered (like EE does) beforehand so the user can’t select a specific datetime to export. |
|
|
Hi Tony, This sounds perfect, so if I use datetimes() to get the closest one to the date specified I can then use ‘Ticket.Datetime.DTT_ID’ => $DTT_ID in the registrations object to pull the correct attendees? Thanks |
Almost, you’ll use the From there you can get the attendees. |
|
The support post ‘Custom Meta Data on profile’ 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.