gform_akismet_enabled

Description

This filter allows default Akismet integration to be disabled globally or per form.

Usage

add_filter( 'gform_akismet_enabled', 'your_function_name' );

To limit the scope of your function to a specific form, append the form ID to the end of the hook name. (format: gform_akismet_enabled_FORMID)

add_filter( 'gform_akismet_enabled_66', 'your_function_name', 10, 2 );

Parameters

  • $is_enabled bool

    Defaults to `true`; return `false` to disable Akismet.

  • $form_id int

    The ID of the form being processed. Since Gravity Forms 2.4.19.

Examples

Disable globally

This example will globally disable Akismet integration with Gravity Forms:

add_filter( 'gform_akismet_enabled', '__return_false' );

Disable for a specific form only

This example will disable Akismet integration with Gravity Forms only for form id 1:

add_filter( 'gform_akismet_enabled_1', '__return_false' );

Using one function with multiple forms

add_filter( 'gform_akismet_enabled', function ( $is_enabled, $form_id ) {
	if ( in_array( $form_id, array( 1, 3, 5 ) ) ) {
		$is_enabled = false;
	}

	return $is_enabled;
}, 10, 2 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

Since Akismet Add-On version 1.1, this filter is located in \Gravity_Forms\Gravity_Forms_Akismet\GF_Akismet::is_enabled_form() in class-gf-akismet.php. It was previously located in Gravity Forms, in GFCommon::akismet_enabled() in common.php.