PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How to Change Gravity Form Base Directory?

  1. I would like to change the base root directory from "/gravity_forms/" to "/forms/". I found an entry at the forms_mode.php, but I would prefer not to change the plugin files. Can I accomplish this with adding a filter to my functions.php file?

    Posted 7 years ago on Sunday August 5, 2012 | Permalink
  2. I've just figured out how to do it. Here's the code you need to add to your functions.php file:

    add_filter("gform_upload_path", "change_upload_path", 10, 2);
    function change_upload_path($path_info, $form_id){
        $upload_dir = wp_upload_dir();
        $dir_base = $upload_dir["basedir"] . "/gravity_forms/"; //change the base path here
        $url_base = $upload_dir["baseurl"] . "/gravity_forms/"; //change the base path here
        $subfolders = wp_hash($form_id)."/".date("Y")."/".date("m")."/";
        $path_info["path"] = $dir_base.$subfolders;
        $path_info["url"] = $url_base.$subfolders;
        return $path_info;
    }
    Posted 7 years ago on Sunday August 5, 2012 | Permalink
  3. Glad you figured it out. Thanks for posting your solution for other folks.

    Posted 7 years ago on Sunday August 5, 2012 | Permalink

This topic has been resolved and has been closed to new replies.