Home › Forums › General Issues › Events Manager and ACF › Reply To: Events Manager and ACF
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) {
//return $value;
if (!is_array($value) || !count($value)) {
// bail early
return $value;
}
$count = count($value);
$now = time();
for ($i=0; $i<$count; $i++) {
$post_type = get_post_type(intval($value[$i]));
$expire = intval(get_post_meta(intval($value[$i]), '_end_ts', true));
if ($post_type == 'event' && $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.