We have been using Event Organiser for a while to list our group’s workshops and recently we have gone with the Pro version for bookings. We have a number of custom fields for our events including a course number field. I’d like to be able to access the course number to put in the emails to admin and customer. Is there any way to do this other than to put the course number actually in the title of the event?
Thanks
http://www.ovwsg.com/?page_id=1067
Judy Kavanagh
Hi Judy,
The following code will create an email placeholder you can use:
EO_Email_Template_Tag_Registry::register( 'myeventfield', function ( $tag, $atts, $context ){
//$tag is 'myeventfield'
//$atts is an array of attributes used with the tag
//$context is an array indexed by 'booking_id', 'event_id', 'occurrence_id' etc. with
//appropriate values for the context of the e-mail.
$custom_field_key = $atts['key']; //or you can hard-code this
$value = get_post_meta( $context['event_id'], $custom_field_key, true );
return $value;
}, 10, 3);
And then you’d use it like this:
%myeventfield key="my_custom_field_key"%
Stephen Harris
Thanks
I just don’t know where to put this: %myeventfield key=”my_custom_field_key”%
Judy Kavanagh
OK, I got it to work, sort of. I put this in my site_utility.php file
EO_Email_Template_Tag_Registry::register( ‘myeventfield’, function ( $tag, $atts, $context ){
//$tag is ‘myeventfield’
//$atts is an array of attributes used with the tag
//$context is an array indexed by ‘booking_id’, ‘event_id’, ‘occurrence_id’ etc. with
//appropriate values for the context of the e-mail.
$custom_field_key = $atts['CourseNumber']; //or you can hard-code this
$value = get_post_meta( $context['event_id'], $custom_field_key, true );
return $value;
}, 10, 3);
It only works if I hard code ‘CourseNumber’. Then I can get the confirmation email to write the course number using
%myeventfield key=”CourseNumber””%
Yay!
But if I have other custom fields I also want to access, how do I do that?
And where do I find the code for the email that goes to the admin? I’d like to put the course number in that email as well.
Thanks!
Judy Kavanagh
Hi Judy,
If you want to use as follows:
%myeventfield key=”CourseNumber””%
Then you should use
$custom_field_key = $atts['key'];
If you want to hardcode and want to create additional email tags, you just copy what you have, but with a different email tag name (i.e. change myeventfield
to something else).
As for the admin notification e-mail, please see this page. It details the filters for changing the admin notification message. Alternatively it provides a link to a plug-in which you can install which adds additional settings to Settings > Event Organiser > Bookings that allow you to change the admin e-mail notification.
Stephen Harris