Hello Tribe,
I’ve added a custom field “TicketLink” with the type URL. And now i want to check if there is any value before displaying the custom field.
This code below fails , why? And what is the proper way to do this?
if(!empty(tribe_get_custom_field(‘TicketLink’))) {
echo tribe_custom_field(‘TicketLink’);
}
Thank you!
Unless you are using PHP 5.5+ you will not be able to do that – empty() only works with variables, not with the direct result of function calls.
Try placing it in a variable first $ticket_link = tribe_get_custom_field(‘TicketLink’) and then test to see if $ticket_link is empty. Also note that tribe_custom_field() echoes the field (if it exists) by itself, so you don’t need that extra echo.