Help Desk

Custom fields in ticket email

  • Posts: 7 Topics: 5
    | Permalink

    Some of the events that we’re selling are hosted at the residential homes of some of our members, and we’d like to keep the location “hidden” from the general public. However, when someone purchases a ticket to the event, we will need to share the event location to our attendees.

    So, I’ve created an additional custom field (private-event-location) for an event using the standard WordPress custom meta fields, and I’d like the content of that custom field to appear ONLY in the ticket that the attendees will receive via email. I have copied the email.php template to my theme folder under /tribe-events/tickets/email.php, and attempted to add the custom field to this template, but so far my early tests have not worked.

    A few questions:

    • Will this approach work?
    • Should I add the custom field to the EVENT (post type), or to the ticket (WooCommerce product)?

    Alternatively, is there an easy way to send a “bulk” email to all of the attendees just prior to the event?j

    Any tips or suggestions would be greatly appreciated. Thank you.

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    Hi Mary,

    That should definitely be possible. In the first instance, please do check out our Themer’s Guide for a high level overview of setting up template overrides:

    theeventscalendar.com/knowledgebase/themers-guide

    In this case specifically, you’ll probably want to make a copy of event-tickets/src/views/tickets/email.php and place that copy in YOUR_THEME/tribe-events/tickets/email.php – you can then safely modify the ticket email.

    If you look inside that, you’ll see that there is a line of code looking like this:

    $event = get_post( $ticket['event_id'] );

    At any point after that, you can therefore access the event and the event’s post ID – and can use that to pull in data from any custom fields you have created, something like this:

    $address = get_post_meta( $event->ID, '_hidden_address_field', true );

    Simply echo or print this data at a suitable point in the flow of the email. Does that help at all?

    Posts: 7 Topics: 5
    | Permalink

    This was exactly what I needed! Thank you for the help.

    Posts: 18146 Topics: 17 Answers: 973
    | Permalink

    My pleasure 🙂

    I’ll go ahead and close this topic since you marked it ‘resolved’, but of course if we can help with anything else please don’t hesitate to post a fresh topic and one of the team will be only too happy to assist.

    Thanks!

    | Permalink