Gravityforms write to SQL with the WPDB plugin

IBM i

Mar 08

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 */

}
Follow

About the Author

IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd 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 in the words of the most interesting man in the world: Stay thirsty my friend.

>