• Home
  • Cloud
    • General
    • SaaS
    • BPaaS
    • PaaS
    • IaaS
    • Other Internet Hosted Applications
      • WordPress
        • WooThemes Canvas
          • WooThemes Canvas CSS
  • About me
  • Why Badly Wired?
  • Contact

Badly Wired

Connecting WordPress via APIs, Plugins and other stuff - a technical notebook

You are here: Home / Tech Tips / Moving where Gravity Forms stores uploads

Moving where Gravity Forms stores uploads

17th October 2014 by Alan Leave a Comment

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

To migrate where Gravity Forms stores uploads, first you need to add a filter to your functions.php

I needed to do this as a wanted a secure place and the default location was giving me problems.

Fully Managed UK Hosting - Only £1+VAT till 1st Jan 2021 on Shared, Reseller and Dedicated Hosting! .... read more ....

Create a directory of your server that is visible from the web, and secure it with .htaccess appropriately e.g.  http://weavervsworld.com/docs/other/passprotect.html

This is code for functions.php

 

<?php
add_filter("gform_upload_path", "change_upload_path", 10, 2);
function change_upload_path($path_info, $form_id){
$path_info["path"] = "/home/mydomain/public_html/safe/";
$path_info["url"] = "http://mydomain.com/safe/";
return $path_info;
}
?>

 

The filter is explained here -> http://www.gravityhelp.com/documentation/page/Gform_upload_path

And then move the files from old place to new, FTP will do fine.

Then you need to update the database to change the location of the old files.   You can use PhpMyAdmin if you have it.

UPDATE wp_rg_lead_detail
SET value = REPLACE( value, 'http://mydomain/wp-content/gravityoldpath/', 'http://mydomain/safe/' )
WHERE value LIKE (
'%http://mydomain/wp-content/gravityoldpath/%'
)

Note the table name may have a non wp_ prefix and on a multi site it will have a blog id , eg.  xx_999_rg …

Note by default Gravity stores uploads in month folders, so you may have to iterate through several months, and you may have to deal with the odd duplicate file if you are combining into one folder.

Obviously, not just apply the code above without thinking about the path names etc as it won’t simply work copying and pasting.

You could extend the filter to user date(‘y’) and date (‘m’) to replicate the folder structures, but I’m not sure if Gravity will create new folders or you would have to code a bit like this, as I haven’t tested it.

<?php
if (!file_exists('path/to/directory')) {
    mkdir('path/to/directory', 0777, true);
}
?>

 

 

 

[Next] Find out where to host WordPress [Read the full article…]

Filed Under: Tech Tips, Useful Images  Tagged: Gravity Forms

About Alan

I'm Alan from Fullworks Digital Ltd, where I develop WordPress Plugins and support and manage WordPress websites.

My day job consists of solving clients' WordPress issues and developing new code and solutions.

I started as a professional programmer in 1979 and had been involved with the IT of business technology in virtually every area that exist.

Badlywired.com is my personal blog and my aide memoire of the many interesting facts that I come across. As I spend a lot of time gathering parts of solutions from the internet and assembling them into my own solutions, and also just learning how to do things, this blog is primarily my 'note book' and a way of giving something back to the online community that has helped me extensively.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Applications
  • Cloud
    • General
    • Google Cloud
    • IaaS
    • Other Internet Hosted Applications
      • Wordpress
        • WooThemes Canvas
        • WooThemes Canvas CSS
    • SaaS
  • Code snippets
  • Discounts
  • Genesis
  • Google Apps for Works
  • Linux
  • News
  • SEO
  • Server setup
  • Services
  • Tech Tips
  • Uncategorised
  • Useful Images
  • Useful Stuff
  • WordPress Hosting
  • WordPress Plugins

Tags

background jobs beadcrumbs bind brandings Cache canvas Centos chrome css fail2ban Find firefox Flash fraud genesis gocardless godaddy Google google maps hackers internet explorer javascript KashFlow Linus linux Magento mapquest maps microsoft mysql news nohup php plugin plugins queens diamond jubilee replace SED SEO skype Varnish Virtualmin Webmin woothemes Wordpress

 

Affiliate and Privacy Notices

This site is free to use, but hopes to cover some costs through affiliate income, some products and links are affiliates and may earn the site advertising income.

Some affiliates use Cookies to track if you purchase from them, this allows them to apportion revenue to us you will need to refer to their specific privacy notices as to how you are tracked.

This site is a participant in the Amazon EU Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.co.uk.

  • Privacy Policy

Copyright © 2021 · Badly Wired