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
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
Hi Stephen, thank you so much, it works! Have a great day!
Ciska