Support

Home Forums Attendee Mover Add-on [Attendee Mover] Hook into event selection list

[Attendee Mover] Hook into event selection list

Posted: April 11, 2019 at 1:24 am


ARAGATO

April 11, 2019 at 1:24 am

When moving an attendee to another event/ticket via the attendee mover addon, the first of the four steps is to select an event.
https://i.imgur.com/TZf0K4n.png

Many of our events have the same title, e.g. “Soccer”, but distinguish themselves only from additional meta data we added, e.g. location.
So we have soccer location A and soccer location B.

When searching for soccer in the first step of the attendee mover the result will be a list of events all with the same title, soccer.
Therefore, I would like to hook into that list and add metadata to the eventname resulting in: soccer at location a…

Since the list is an ajax call to the generall debug actions and filters does not work. I have looked into the script of the attendee mover addon and found the EE_Attendee_Mover_Event_Select2 which is probably responsible for the list generation. However, I could not find which function it calls in the “backend”.

I investigated furhter and came to the “EE_Select_Ajax_Model_Rest_Input” Class which probably handles all ajax calls for the EE4 REST API. Unfortunately, I could not find a way to intercept/alter the way the ajax data for that particular case can be hooked into/altered?

Any clues/tips?


Tony

  • Support Staff

April 12, 2019 at 7:31 am

Hi ARAGATO,

This isn’t actually a case of hooking into the ‘backend’ to change this, the backend is the REST API and then the data is formatted through JavaScript.

There’s an example Josh created for modifying the output shown there here:

https://gist.github.com/joshfeck/1e1b43a47a6034b768d6ba125dd53fdf

It doesn’t pull additional information from the REST API (which you will need to do for your request) but gives you an idea of how to change the output and give you a base to work from.


ARAGATO

April 15, 2019 at 4:30 am

So, with Josh’s example I pretty much overwrite the attendee-mover-event-selector.js which is provided by the plugin.

But I still do not get how I can add additonal data to the data variable (which is filled by the EE4 REST API?).
https://i.imgur.com/wPBdWLT.png

I see the parameters being set.
https://i.imgur.com/p6vs2cY.png

But I do not see/know how to fill the response, the data variabel in in particular. Tehre is the EVT_name in the data variable. How do I catch that AJAX request in the backend and add like “ATT_email” to the data response?


Tony

  • Support Staff

April 15, 2019 at 10:09 am

How do I catch that AJAX request in the backend and add like “ATT_email” to the data response?

From the event? You don’t. ATT_email is from an EE_contact, which will be linked to an EE_registration.

I’m not sure why you would try to pull ATT_email on the event selection request?

Apart from that, again, you don’t hook into the REST API to add additional details, the js file is used to send a request to the an endpoint and then the response is returned, you can then pull whatever data you want from that response within the JS file.

In this screenshot – https://imgur.com/p6vs2cY

You highlight where the parameters for the REST API are passed, but again, your on the event selection step meaning the request is sent to the event enpoint and will not have anything to do with the attendee, meaning ATT_email isn’t relevant here.

Unless I’m misunderstanding what you are trying to do?


ARAGATO

April 16, 2019 at 5:00 am

The “ATT_email” was just an example for a some random meta data.

To be more specific. For each event, there is additional metadata written to post_meta (event id = post id), e.g. metadata1, metadata2

I want that metadata1 and metadata2 to be concatenated to the event name in that attendee mover event search box, i.e “Event 1 (metadata1) (metadata2)”.

Apart from that, again, you don’t hook into the REST API to add additional details, the js file is used to send a request to the an endpoint and then the response is returned, you can then pull whatever data you want from that response within the JS file.
Yes, but how do I add additional data, metadata1 and metadata2, tho the reponse data object?


Tony

  • Support Staff

April 16, 2019 at 9:38 am

The “ATT_email” was just an example for a some random meta data.

Then you’ll need to be much more specific with those types of examples.

ATT_email is not ‘some random meta data’ within Event Espresso, ATT_email is specific to an EE_Contact and nothing to do with an event. The section you are working on relates to events, which means ATT_email makes no sense in that context, throwing it into the request with no meaning causes more confusion for both you and me.

Yes, but how do I add additional data, metadata1 and metadata2, tho the reponse data object?

You tell the REST API to include those fields when sending the request.

We have documentation on the REST API here:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/C–REST-API

And specifically for adding additional fields/models to the request here:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/C–REST-API/ee4-rest-api-GET-including-specific-fields-and-related-entities-in-results.md

I’d also recommend installing the REST API log plugin so you can what happens to the requests when you change the includes. You can also do that with Chrome Dev Tool and follow the network calls then view the response, buts it’s a little easier to view with the log plugin.

The support post ‘[Attendee Mover] Hook into event selection list’ 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.

Status: closed

Updated by  Tony 7 months, 3 weeks ago ago

Topic Tags

Tagged: , , ,

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!