Check if custom field is empty

Home Forums Calendar Products Events Calendar PRO Check if custom field is empty

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #62768
    soesit
    Participant

    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!

    #63143
    Barry
    Member

    Hi soesit:

    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.

    Does that help at all?

    #63254
    soesit
    Participant

    Yes it works! Thank you for explanation and the awesome support 🙂

    #63265
    Barry
    Member

    No problem – happy to help 🙂

    #980409
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Check if custom field is empty’ is closed to new replies.