Problem registering custom field to be displayed in booking confirmation email

WordPress Event Management, Calendars & Registration Forums General Question Problem registering custom field to be displayed in booking confirmation email

This topic contains 2 replies, has 2 voices, and was last updated by  Ciska 4 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38409

    Dear Stephen,

    I have just created a custom field (with ACF) called ‘zoom_link’. This field is meant for Zoom-links of our online events.

    To display this field in the frontend, I copied the file ‘event-meta-event-single.php’ into the theme folder and added the following PHP snippet (which I got from an ACF support page):

      <!-- Can the event be followed online via Zoom? -->
    <?php 
        $link = get_field('zoom_link');
            if( $link ): ?>
                <a>">Zoom link</a>
    <?php endif; ?>
    

    So far, everything works fine. The link properly shows up in the frontend as a button. However, as a non-programmer with no knowledge of PHP, I got stuck with the final bit – registering the new field, so it can be displayed in the booking confirmation mail as well.

    Based on the code snippet you provided in a related topic, I tried to put together my own code, but unfortunately it does not work:

    <?php
        add_action('init', function(){  
                EO_Email_Template_Tag_Registry::register( 'zoom_link', function($tag, $atts, $context ){
    
                   $event_id = $context['event_id']; 
                   //Get Zoom link from event custom field:
                $zoom_link = $link;
                   return "<p>Zoom link: ${'link'}</p>";
                });
            });
    <?php endif; ?>
    

    When I embed %zoom_link% in the email template, the “Zoom link: ” bit is shown, but the actual link is missing.

    Sorry to bother you with such beginners issues, but I hope you can help me out…

    Ciska
    #38443

    I’ve not used ACF, but try the following

    <?php
        add_action('init', function(){  
                EO_Email_Template_Tag_Registry::register( 'zoom_link', function($tag, $atts, $context ){
    
                   $event_id = $context['event_id']; 
                   $link = get_field('zoom_link', $event_id);
                   return "<p>Zoom link: $link</p>";
                });
            });
    <?php endif; ?>
    
    Stephen Harris
    #38456

    Hi Stephen, thank you so much, it works! Have a great day!

    Ciska
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.