Gravityforms write to SQL with the WPDB plugin 

 March 8, 2018

By  NickLitten

This week I ‘ave mostly been… trying to create a Gravity Form to allow users to pay for a Memberpress subscription using Stripe and then login and immediately get access to the subscribed content. Apart from that, I want to store my form data so I can review the new customer information from my SQL database at anytime – step up the WPDB Connect Plugin which does this job admirably…. ish…

With one small but very annoying error.

Strangely enough – I only see this error message for users subscribing when they are not logged in.

Notice: Undefined variable: form in /wp-content/plugins/gravityforms_wpdb-connect/class.gravityforms_wpdb-connect.php on line 611

I looked around while I’m waiting for the support team to write a proper fix and I found a nice little quick and dirty solution: we can check if this PHP variable exists before we use it. If it doesn’t exist then we are here in error so gracefully. It goes to sleep nicely, still works as planned and just quietly gets on with thing without spitting out any angry error messages.

Simply go and edit /wp-content/plugins/gravityforms_wpdb-connect/class.gravityforms_wpdb-connect.php

Add the lines I marked as NJL

 * process the feeds after the entry was changed with the GFAPI
 * @param object $entry the current entry
 * @param object $original_entry the entry before the changes
 * @return

function spgfwpdb_gform_post_update_entry( $entry, $original_entry )

/** NJL added by to capture undefined $form variable */
 if(isset($form)) {

 * loop thru and process the feeds
 $feeds = GFAPI::get_feeds( NULL, $entry[ 'form_id' ], $this->_slug );
 foreach( (array)$feeds AS $feed )
 self::process_feed_update( $feed, $entry, $form );

} /** NJL */



IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

I’m always looking for awesome input, feedback and critique!