Support

Account

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.