gform_akismet_enabled

gform_akismet_enabled

DescriptionUsageParametersExamplesDisable globallyDisable for a specific form onlyUsing one function with multiple formsPlacementSource Code

Description
This filter allows default Akismet integration to be disabled globally or per form.
Usage
add_filter( 'gform_akismet_enabled', 'your_function_name', 10, 2 );

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_6', '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 2.4.18.5.

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 should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::akismet_enabled() in common.php.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注