Posted: April 7, 2021 at 9:01 pm
|
I would like to associate a question group to an event but I can’t seem to find the correct model to use. I see event_question_group, but when I look at wp-json it’s showing no args. Is there an easy way to associate a question group to an event if I know the question group ID? |
|
On a side note, I just want to have the same question group applied to each event. I did look at this post but I am confused on where I can specify which question group I want to assign to the event |
Hi make_webmaster, Are you looking to do this dynamically via the REST API? You would just need to place that code into an appropriate place on your site for running code (ex: your theme’s functions.php file, or a custom plugin (best option)) but then change the number in So for example, if you created a new custom question group that had a
If you DO want to do this via the REST API, then the request would look something like:
where 9 would be the ID (EVT_ID) for the event you want to add the relation to and 3 is the ID (QSG_ID) of your question group.
|
|
|
Hi Brent, I was able to figure this one out. I am using the model structure and so I was trying to figure out how to pull a certain question group and associate it dynamically to the event. $qgroups = EEM_Event_Question_Group::instance()->get_one_by_ID(3); |
Hi there, Just a quick note to second that if you have access to the site, go with the models. The EE REST API uses them anyway so you basically cutting out the middleman and doing it directly. Also, there are methods on the event model to add/remove question groups:
and
So if you want to clean the above a little you could switch to:
You’ve already hard coded the ID in the above but don’t state if this is for Primary Registrants or both, if both primary and additional you’ll also need:
Less code and a little more obvious what it is doing but ultimately up to you on what you want to use 🙂 |
|
The support post ‘Associate question group to an event’ 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.