Skip to main content

Filter: gform_pre_execute_ability

Short-circuits ability execution.

Runs after the permission check passes, so it can only restrict or substitute — never bypass authorization. Return a WP_Error to block execution (rate limiting, maintenance freezes, per-ability kill switches), or any other non-null value to use it as the result without running the ability callback (caching, stubbing). Substituted results are still validated against the ability's output schema. Blocked and substituted executions fire gform_after_execute_ability normally, so they remain visible to the audit log.

Parameters​

NameTypeDescription
$premixedNull to run the ability normally. WP_Error to block, any other non-null value to short-circuit with that result.
$ability_namestringThe registered ability name.
$inputarrayThe input passed to the ability.
$ability_object\GF_AbilityThe ability instance being executed.

Example​

add_filter( 'gform_pre_execute_ability', function( $pre, $name, $input ) {
if ( 'gravityforms/entries-delete' === $name && my_plugin_is_freeze_window() ) {
return new WP_Error( 'my_plugin_freeze', __( 'Deletions are paused during the deploy window.', 'my-plugin' ) );
}
return $pre;
}, 10, 3 );

Since​

  • 3.1.0

Source​

Defined in includes/abilities/class-gf-ability.php at line 176