Support

Account

Home Forums Add-ons Repeater Field Show field x if field y contains… Reply To: Show field x if field y contains…

  • 
    $bookingfield = get_field('accom_booking_link');
    
    // full url as returned by acf will be needed in if statements
    // I would use a switch because it's a url field the user could enter anything
    
    switch ($bookingfield) {
      case 'http://www.booking.com/':
        // do something
        break;
      case 'http://www.ezyrez.com/':
        // do something else
        break;
      default:
        // not one of the sites
        echo 'Invalid Booking Site';
    }
    

    I would not use a URL field here, the main reason being that you are only providing for 2 choices but the user can select from an unlimited number of urls.

    I would us a select field, or a radio field so they can only select from the ones I’m prepared to support. In this case the logic would be the same because you can always add more choices later. You would just change out the cases in the switch statement base on the values of the select field.