1. Home
  2. Docs
  3. Protect WordPress Uploads
  4. Hooks & filters

Hooks & filters

Filter private_media_url_by_array:

This filter will change a protected file to the right URL /download/file/123/. This could be used if you have linked somewhere in your post, page or product. 

<?php echo apply_filters( 'private_media_url_by_array', $file ); ?>

Filter acf/upload_prefilter:

This filter can be used to protect WordPress uploads when uploading files in ACF.

<?php
if(class_exists('PWPF_Hooks') && class_exists('acf')){
$PWPF_hooks = new PWPF_Hooks;
$field_name = !empty($name) ? $name : 'file'; // Change the $field_name to your ACF field name
add_filter('acf/upload_prefilter/name=' . $field_name, array($PWPF_hooks, 'PWPF_acf_upload_prefilter'), 10, 3);
}
?>

 

 

How can we help?