Home Forums Backend Issues (wp-admin) Change file upload path to WP Root? Reply To: Change file upload path to WP Root?

  • Had this exact issue, wrote a blog post about it here:

    But your code would end up looking something like:

    add_filter( 'acf/upload_prefilter/name=secure_files', 'secure_upload_prefilter' );
    add_filter( 'acf/prepare_field/name=secure_files', 'secure_files_field_display' );
    public function secure_upload_prefilter( $errors ) {
      add_filter( 'upload_dir', 'secure_upload_directory' );
      return $errors;
    function secure_upload_directory( $param ) {
      $folder = '/s2member-files';
      $param['path'] = WP_PLUGIN_DIR . $folder;
      $param['url'] = WP_PLUGIN_URL . $folder;
      $param['subdir'] = $folder;
      $param['basedir'] = WP_PLUGIN_DIR;
      $param['baseurl'] = WP_PLUGIN_URL;
      return $param;
    public function secure_files_field_display( $field ) {
      // update paths accordingly before displaying link to file
      add_filter( 'upload_dir', 'secure_upload_directory' );
      return $field;

    Where the secure_files portion of the add_filter would be your field name instead.

    Then in the secure_upload_directory() function you could use to grab the absolute path to the install location.