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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.