Support

Account

Home Forums General Issues If field A has value but field B does not…

Helping

If field A has value but field B does not…

  • Hi,

    I’m trying to create and if/and statement to show data if certain sets of fields match. For example, I have field A and field B, I want to create a conditional statement that will show something only if field A has a value and field B does not. The catch is I need multiple.

    This currently works;

    <?php if( get_field('additional_person_1_first_name') && get_field('additional_person_1_director_role') == '' ): ?>

    But this doesn’t;
    <?php if( get_field('additional_person_1_first_name') && get_field('additional_person_1_director_role') == '' ) || get_field('additional_person_2_first_name') && get_field('additional_person_2_director_role') == '' ): ?>

    What am I missing?

  • You’re IF statement is incorrect. Try:

    if ( ( get_field('additional_person_1_first_name') && get_field('additional_person_1_director_role') == '' ) || ( get_field('additional_person_2_first_name') && get_field('additional_person_2_director_role') == '' ) ) :

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.