Home › Forums › Front-end Issues › Only the last condition outputs as data-condition › Reply To: Only the last condition outputs as data-condition
I think I should FOREACH a part of the array. ? Is that a correct thinking?
Although this does not work, could you help me please? This is the last part in a long journey to develop my own booking system:
// Apply conditions to fields
add_filter('acf/prepare_field/name=bookings_field_time_session_1', 'yl_check_booking_exeptions_session_1');
function yl_check_booking_exeptions_session_1( $field ) {
// Retrieve option values. Date value should be like: 20200611 (unformatted)
$rows = get_field('bookings_settings_disabled_exceptions', 'bookings');
if( $rows ) {
foreach ( $rows as $row ) {
$option_date = get_sub_field('bookings_settings_disabled_date', 'bookings', false);
$date = date_i18n('Ymd', strtotime($option_date));
$session = get_sub_field('bookings_settings_disabled_session', 'bookings', false);
$arrays =
array(
array(
'field' => 'field_5ed4181bd63dc', // Time field session 1 in the form
'operator' => '!=', // If Value is different, then show the field
'value' => $session, // Compare against option page value
),
array(
'field' => 'field_5ed4178dd63d7', // Datepicker fiels in the form
'operator' => '!=', // If Value is different, then show the field
'value' => $date, // Compare against option page value
)
);
}
if ( $session == '1' ) {
$field['conditional_logic'] = array(
$arrays
);
}
}
// Return
return $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!
Our guide looks into WordPress custom fields and how they stack up against the possibilities of ACF.
— Advanced Custom Fields (@wp_acf) July 18, 2022
https://t.co/hk3yibkHyk
© 2022 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.