wp_ability_execute_result
Filters the result returned by an ability's execute callback.
Fires after the registered execute callback runs. Plugins can use this to transform the result — response formatting, stripping internal metadata, content safety filtering, response enrichment, or recovering from a failure by returning a successful value.
The filter receives whatever the registered callback produced, including a WP_Error if execution failed. Filters may pass the WP_Error through unchanged, override it with a recovered result, or convert a successful result into a WP_Error.
Usage
add_filter( 'wp_ability_execute_result', 'wp_kama_ability_execute_result_filter', 10, 4 );
/**
* Function for `wp_ability_execute_result` filter-hook.
*
* @param mixed $result The result returned by the registered `execute_callback`, or a `WP_Error` if execution failed.
* @param string $ability_name The name of the ability.
* @param mixed $input The normalized input data.
* @param WP_Ability $ability The ability instance.
*
* @return mixed
*/
function wp_kama_ability_execute_result_filter( $result, $ability_name, $input, $ability ){
// filter...
return $result;
}
- $result(mixed)
- The result returned by the registered
execute_callback, or aWP_Errorif execution failed. - $ability_name(string)
- The name of the ability.
- $input(mixed)
- The normalized input data.
- $ability(WP_Ability)
- The ability instance.
Changelog
| Since 7.1.0 | Introduced. |
Where the hook is called
wp_ability_execute_result
wp-includes/abilities-api/class-wp-ability.php 701
return apply_filters( 'wp_ability_execute_result', $result, $this->name, $input, $this );