Adding Custom Field to Notification email

Home Forums Calendar Products Community Events Adding Custom Field to Notification email

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1017648
    Mad Dog
    Participant

    I’m trying to add two custom fields to the Notification Email by editing email-template.php and there are various methods I see in the forum and Documentation, none are working for me. The field name is ‘Instructor”. Seems it should be simple. Here’s the latest I’m using….what am I doing wrong?

    <?php echo 'Instructor: ' . tribe_get_custom_field('Instructor', $event->ID); ?>

    It returns the text but not the custom field.

    Thanks!

    #1017882
    George
    Participant

    Hey @Mad Dog,

    I’m sorry that you’re having trouble with your customizations! Before we get started, I would like to highlight that we cannot offer any support for custom code.

    With that being said, in general one thing that is not helping your code along is that the function tribe_get_custom_field(), singular, is these days a deprecated function.

    So your best option would be to use the annoyingly-similar plural version of this function: tribe_get_custom_fields()

    Here’s a rough version of your original code rewritten to use this function, which may not fix your problems outright, but is an essential step before any others:


    $fields = tribe_get_custom_fields( $event->ID );

    if ( isset( $fields['Instructor'] ) ) {
    echo 'Instructor: ' . $fields['Instructor'];
    }

    I hope this helps!

    #1017948
    Mad Dog
    Participant

    Thanks! The only change needed was to use $post instead of $event since the email is going out when you create the post.

    <?php $fields = tribe_get_custom_fields( $post->ID );

    You might pass along to someone to mark tribe_get_custom_field (singular!) as deprecated in the Documentation.

    Thanks again for the assist!

    MD

    #1018054
    George
    Participant

    Great! Thanks for the update here @Mad Dog – best of luck with your site going forward 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Adding Custom Field to Notification email’ is closed to new replies.