Support

Account

Home Forums ACF PRO ACF Pro acf/upload_prefilter not working?

Helping

ACF Pro acf/upload_prefilter not working?

  • Hi all,

    I have a simple form with a file upload and I’m attempting to intercept it with the ‘upload_prefilter’ filter, but it’s just not working!

    My code is as follows:

    
    function my_acf_upload_prefilter( $errors, $file, $field ) {
    
        $errors[] = 'computer says no';
    
        // return
        return $errors;
    
    }
    
    add_filter('acf/upload_prefilter/name=unique_upload_image', 'my_acf_upload_prefilter');
    

    I thought this would just cause the upload to fail for the field named ‘unique_upload_image’ – but it continues to work fine.

    Am I doing something stupid here?

    Thanks
    Kevin

  • OK my bad, I was forgetting my namespacing!!!

    Should have been:
    add_filter('acf/upload_prefilter/name=unique_upload_image', '\App\my_acf_upload_prefilter');

    However, although this now works, it’s still not displaying the error message I defined, it’s just saying ‘HTTP error’?

    Any ideas?
    Kev

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘ACF Pro acf/upload_prefilter not working?’ is closed to new replies.