Description
The gform_pre_execute_ability filter runs after an MCP tool’s permission check passes, just before the tool executes.
Note: Blocked and substituted calls still trigger the after-execute action, so they remain visible in audit logging.
Usage
The following would apply to all abilities.
add_filter( 'gform_pre_execute_ability', 'your_function_name', 10, 4 );
Parameters
| Parameter | Type | Description |
|---|---|---|
| $pre | null | The short-circuit value. Return non-null to skip execution and use your return value as the result. Defaults to null. |
| $ability_name | string | The name of the ability being executed, e.g. gravityforms/entries-delete. |
| $input | array | The input parameters are being passed to the ability. |
| $ability | object | The ability object being executed. |
Examples
Pause Deletions During a Deploy Window.
add_filter( 'gform_pre_execute_ability', function ( $pre, $name, $input ) {
if ( 'gravityforms/entries-delete' === $name && my_site_is_deploying() ) {
return new WP_Error( 'deploy_freeze', 'Deletions are paused during the deploy window. Try again in a few minutes.' );
}
return $pre;
}, 10, 3 );
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
This filter is located in gravityforms/includes/abilities/class-gf-ability.php
Since
The filter was added in Gravity Forms 3.1.0