I would like to attach Attendee Questions to just one of several EO forms on my site. Is it possible to use a simple conditional around the Attendee Questions code, such as:
function my_attach_attendee_questions( $form ) {
if ( [form ID] === [ID] ) {
[Attendee Questions code]
}
}
If so, how exactly do I address the form ID? Is it ‘$form->id’? Please excuse my ignorance.
Michael Docker
I seem to have figured this out for myself:
function my_attach_attendee_questions( $form ) {
$form_name = $form->get( 'name' );
if ( $form_name === 'test-form' ) {
[Attendee Questions code]
}
}
That does the trick.
In answer to a previous question you suggested that it would be possible to ‘use some javascript to pre-fill the first set of fields’ in the Attendee Questions. Where would that javascript go? Unlike WordPress pages and posts there doesn’t appear to be a place for Scripts in the Event editor.
Michael Docker
Hi Michael,
Scripts would have to be loaded using the WordPress api (e.g. wp_enqueue_script
).
As for the JavasScript itself, you could use jQuery to listen to changes in the attendee question div, and if the first section is empty, pre-populate it with the relevant details. All fields and container divs should have appropriate classes so you can target them.
Stephen Harris