Home › Forums › General Issues › Events Manager and ACF › Reply To: Events Manager and ACF
I made an adjustment. It appears that the values in the array are strings at this point and they need to be integers.
add_filter(
'acf/load_value/name=YOUR_FIELD_NAME_HERE',
'remove_expired_events_form_YOUR_FIELD_NAME_HERE',
10, 3
);
function remove_expired_events_form_YOUR_FIELD_NAME_HERE($value, $post_id, $field) {
var_dump($value);
if (!is_array($value) || !count($value)) {
// bail early
return $value;
}
$count = count($value);
$now = time();
for ($i=0; $i<$count; $i++) {
// adjusted this line
$expire = intval(get_post_meta(intval($value[$i]), '_end_ts', 0));
if ($expire < $now) {
unset($value[$i]);
}
}
return $value;
}
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.