wppaste
WordPress

apply_filters( 'wp_ability_permission_result', bool|WP_Error $permission, string $ability_name, mixed $input, WP_Ability $ability )

Since
7.1.0
Filters the result of an ability's permission check.

Description

Fires after the registered permission_callback returns. Plugins can use this to layer additional authorization rules on top of the ability's own permission logic — for example, multi-factor authorization gates or temporary permission elevation for trusted contexts.

Filters can return true to grant, false to deny, or a WP_Error to deny with a specific error code and message. The filter receives whatever the permission_callback produced.
Any other return value is coerced to false.

Compatibility

WordPress
since 7.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 1 of the 5 tracked releases, added in 7.1.0.

Parameters

$permissionbool|WP_Error
The permission result returned by permission_callback.
$ability_namestring
The name of the ability.
$inputmixed
The input data for the permission check.
$abilityWP_Ability
The ability instance.

Where this hook fires · 1

  • wp-includes/abilities-api/class-wp-ability.php:652WP_Ability::check_permissions()

Source code

		 *		 * @param bool|WP_Error $permission   The permission result returned by `permission_callback`.		 * @param string        $ability_name The name of the ability.		 * @param mixed         $input        The input data for the permission check.		 * @param WP_Ability    $ability      The ability instance.		 */		$result = apply_filters( 'wp_ability_permission_result', $permission, $this->name, $input, $this );		if ( ! is_bool( $result ) && ! is_wp_error( $result ) ) {			$result = false;		}		return $result;	}

Changelog

Introduced in 7.1.0.

Signature, return type and hooks compared across 1 parsed release.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.