Welcome Guest! Login? Checkout

Okay, let me get it out there, I love Akismet. It has saved me so much time on the account I simply don’t have any reason to check spam. It’s truly something that you can set and forget, and really you should pay for it.

Another great plugin you should pay for is Gravity Forms, it is well coded, extensible, with lots of extensions, and some great built in features. One such in built feature which is switched on automatically is spam checking messages with Akismet. It’s something you should leave switched on.

However, there may be the odd occasion where you have to switch it off.

Say, for example, you have a Gravity Form which allows logged in users to submit posts. Logged in users are provisionally spam checked, so you don’t need to check for spam again. Furthermore, Gravity Forms’ spam filter after the form contents is saved, but before it is saved as a standard post. So if the message is flagged as spam, the user will not see his post go live, and it won’t be present in the Posts section of the WordPress dashboard. Intstead it is hidden in the “Spam” section of the entries field.

In situations like this, it makes sense to disable Gravity Forms’ spam filters. Although there isn’t a tickbox or a setting on a form or sitewide, you can do this with a few lines of code.

There is a filter – gform_akismet_enabled – that allows you to disable Akismet on individual forms or on all forms (which I wouldn’t recommend). To disable it, get your form ID (which you can find on the Forms page), and add it to the end of the hook. So for this example, we’ll use ID of 1.

So, to disable Akismet on this form, simply do the following:-

It’s generally a good idea to have this in a function, as should you need to add to more than one form, you can call it, plus it maintains backwards compatibility:-

Anyway, that’s how you disable the Gravity Forms spam filter. 99% of the time you should leave it on. However on the rare occasions you need to switch it off, that’s how to do it.

 
 
 

Comments

Polite Disclaimer: I am welcome, open and willing for corrections to be shared in the comments (with corrections being added to posts and credited), and the comments field should be used to promote discussion and make this post better. I do not know everything and if anybody finds a better way to do something, then by all means please share it below.

However, I'm unable to offer support to posts. The reason being is that WordPress has tens of thousands of plugins and millions of themes. As such, finding out exactly why code doesn't work with your setup is a long process. If you wish for me to look at your code, please use the priority support area.

Comments asking support will be left on the site, but there is no guarantee of answer.

  • Richard Wawrzyniak

    Hi Rhys,

    Great post, I’m sure it will help a lot of users. It’s worth noting there is a sitewide setting for disabling the Akismet integration on the Forms > Settings page.

    Also in Gravity Forms 1.8.17 we introduced the gform_entry_is_spam hook which allows developers or users to perform their own spam check and return true or false. There’s also a form specific version.

    add_filter( 'gform_entry_is_spam', 'it_is_all_spam', 10, 3 );
    function it_is_all_spam( $is_spam, $form, $entry ) {
    // perform custom check
    return true;
    }

    I believe there are some third-party plugins and add-ons already making use of this hook.

    January 14, 2015 at 12:19 pm
    • Rhys Wynne

      Thanks for the comment Richard, do appreciate it :)

      Wasn’t aware of the sitewide switch off, should be more useful than relying on the code, and good to hear about the custom checker. Thanks for your great comment!

      January 14, 2015 at 12:28 pm
  • Jem

    Either I’m being dense or there *isn’t* actually a setting for Akismet on Forms > Settings…

    January 14, 2015 at 1:36 pm
    • Richard Wawrzyniak

      The Akismet Integration setting appears between the No-Conflict Mode and Currency settings, it is only present when Akismet is installed and active.

      January 14, 2015 at 1:40 pm
  • Jem

    Ignore me, looks like the client has removed Akismet. That would explain why I can’t see it… ;)

    January 14, 2015 at 3:11 pm
  • Pascal Birchler

    Hi Rhys,

    When I first read the title, I couldn’t think of a scenario where this might be useful, but it looks like there is one :)

    You could make your functions even simpler with using the __return_false() function WordPress already provides, which simply returns false.

    add_filter("gform_akismet_enabled_1", "__return_false");

    January 14, 2015 at 3:23 pm

Comments are closed.