How to Fix ‘get_result() on null’ for Contact Form 7
The ‘get_result() on null’ for Contact Form 7 error presents itself in a pretty apparent way.
How It Looks on the Front End
On form submission, the entire form redirects to a CF7 website URL with a hash identifier and a classic WordPress critical error. Like so:
And in Your Error Log
PHP Fatal error: Uncaught Error: Call to a member function get_result() on null in your-site-info/wp-content/plugins/contact-form-7/includes/contact-form.php:989
It Was Fine Before …
Something Changed, and It Might’ve Not Been You
Is this new? It’s likely one, or a mix, of the following scenarios:
- Your version of WordPress was updated
- Your version of PHP was updated
- Or something on your server configuration modified
Often times server providers will do any of these three changes automatically in the background — sometimes without apparent notice.
The solution is simple: upgrade your version of Contact Form 7. Whatever version you’re using is out of sync with how WordPress and/or your server is working together.
The fastest way to do this is to:
- Head to your WordPress admin dashboard
- Hit Plugins on the sidebar
- Navigate to Contact Form 7
- Click the Update button
BUT WAIT! Before you do that, back your site up and use a Staging area to test your changes.
WordPress Might Need an Upgrade, Too
If you’re upgrading to the latest version of Contact Form 7, and your version of WordPress is behind, it will prompt you to upgrade that too.
- This certainly requires a backup and Staging area just to verify everything is in working order across the site itself.
Need to Avoid a WordPress Update? Leverage a Legacy Version of Contact Form 7
Just be sure it’s older than the version you’re using to avoid the get_result issue.
You can manually download older versions here.
To install, head to Plugins and hit the Upload button.
Update the Plugin, Immediately Test, and Ignore Visual Miscues (for Now)
Once the Upgrade is done, don’t worry about any visual discrepancies. We need to verify this fixed the issue.
Head to your form page and try it again.
If it works, congratulations Contact Form 7 is now in line with whichever of the three items was out of alignment per the above.
Fixing the Visual Miscues
Versions of Contact Form 7 have several key differences you need to be aware of.
The Changes
Between the 5.5 and 5.6 (current version as of this article is 5.9+) Contact Form 7 reconfigured a few major things.
- They started auto-adding Paragraph tags <p> on line breaks. The long and short is that you might see a whole lot more of these all of the sudden, which will potentially wreak havoc on your styling
- And, more importantly if you’re utilizing some class-based jQuery commands, they removed the name of fields from the parent <div> replacing those all with data-name HTML objects
The Fixes
In short:
- You can reconfigure your forms to eliminate <p>s, which are implemented anytime there is a hard break (basically whenever you hit enter to a new line within the Contact Form 7 builder)
- You can reconfigure your jQuery to use data-name lookups instead of class-name look ups
But, let’s say you’re dealing with a massive, complicated website and you can’t afford to reconfigure to this level of depth, especially if you’re in a pinch.
Here are two quick solutions:
Eliminating those Extra <p> Tags
Head to functions.php and drop this code:
add_filter('wpcf7_autop_or_not', '__return_false');
This will fix all of those new <p> tags, however, you might have to drop some additional CSS to make any non-full-width objects 100% width again.
Adapting jQuery Relying on Class Names
You’ll also want to drop this script on every page relying on Contact Form 7:
$('.wpcf7-form-control-wrap').each(function() {
var dataName = $(this).data('name');
if (dataName) {
$(this).addClass(dataName);
}
});
This will restore classes to the HTML objects your other scripts are relying on.
Not sure you need this? I’d recommend using it anyway as a catchall, unless it causes other errors.
Test It
When this is all implemented, be sure to test all of your contact forms before marking it complete.
Then verify that all scripts and integrations are operating as intended.
Still Not Working?
If that didn’t do the trick, well, then I’m sorry to give you the most generic advice on the internet but …
- Start disabling Plugins one-by-one to see if one is the culprit
- Does it work? Then there is a Plugin conflict
- If that doesn’t work, restore to a generic base WordPress Theme and test it again
- If it works when you do this, then there is a Theme conflict
Need Development Help?
Does this look like a whole bunch of nonsense? We’re here to help.
Reach out today and we will reply within same business day (Monday through Friday 9am-5pm EST) or within 24 hours if outside of those hours.