Support

Account

Home Forums Backend Issues (wp-admin) Change file upload path for one specific field. Reply To: Change file upload path for one specific field.

  • I know this is a very old topic and you have either figured this our or moved on by now. This is for others that might be trying to do the same thing since I have recently done something similar.

    You need to add a couple of filters. The first is for the upload prefilter

    
    add_filter('acf/upload_prefilter/name=field_name', 'field_name_upload_prefilter');
    function field_nameupload_prefilter($errors) {
      // in this filter we add a WP filter that alters the upload path
      add_filter('upload_dir', 'field_name_upload_dir');
      return $errors;
    }
    // second filter
    function field_name_upload_dir($uploads) {
      // here is where we later the path
      $uploads['path'] = $uploads['basedir'].'/your_path_dir';
      $uploads['url'] = $uploads['baseurl'].'/your_path_dir';
      $uploads['subdir'] = '';
      return $uploads;
    }