Home › Forums › General Issues › acf/upload_prefilter – for every field on options page › Reply To: acf/upload_prefilter – for every field on options page
Usually, when I want to target a lot of fields with the same filter it’s something like
$fields = array(
'field_123456',
'field_234567',
// etc for each field
);
foreach ($fields as $field_key) {
add_filter('acf/upload_prefilter/key='.$key, 'my_upload_prefilter');
}
function my_upload_prefilter($errors) {
// filter function code
}
You probably don’t want to use anonymous functions like your first example. but you probably could.
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.