Gravityforms write to SQL with the WPDB plugin

  • Home
  • /
  • Blog
  • /
  • Gravityforms write to SQL with the WPDB plugin

March 8, 2018

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

}

NickLitten


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"}

Start your
7-day free trial

Take This Course with ALL ACCESS

Unlock your Learning Potential with instant access to every course and all new courses as they are released.
 [ For Serious Software Developers only ]

IBM i Training For Technology Experts

New!

Successfully Work Remote 

 $ 129.00  $59.00

By adding new skills in information technology, employers will be confident that you have the necessary skills and tools needed to successfully work remotely

>

Snug CBD

 20% Discount

I have partnered with SNUG CBD givING you Organic CBD
20% discount code "NL20"