Title: WP_Abilities_Registry::register
Published: February 24, 2026

---

# WP_Abilities_Registry::register( string $name,  $args ): 󠀁[WP_Ability](https://developer.wordpress.org/reference/classes/wp_ability/)󠁿|null

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#wp--skip-link--target)

Registers a new ability.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#description)󠁿

Do not use this method directly. Instead, use the `wp_register_ability()` function.

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#see-also)󠁿

 * [wp_register_ability()](https://developer.wordpress.org/reference/functions/wp_register_ability/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#parameters)󠁿

 `$name`stringrequired

The name of the ability. The name must be a string containing a namespace prefix,
i.e. `my-plugin/my-ability`. It can only contain lowercase alphanumeric characters,
dashes and the forward slash.

mixed> $args { An associative array of arguments for the ability.
 @type string 
$label The human-readable label for the ability. @type string $description A detailed
description of what the ability does. @type string $category The ability category
slug this ability belongs to. @type callable $execute_callback A callback function
to execute when the ability is invoked. Receives optional mixed input and returns
mixed result or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/).
@type callable $permission_callback A callback function to check permissions before
execution. Receives optional mixed input and returns bool or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/).
@type array<string, mixed> $input_schema Optional. JSON Schema definition for the
ability’s input. @type array<string, mixed> $output_schema Optional. JSON Schema
definition for the ability’s output. @type array<string, mixed> $meta { Optional.
Additional metadata for the ability. @type array<string, `bool|null`> $annotations{
Optional. Semantic annotations describing the ability’s behavioral characteristics.
These annotations are hints for tooling and documentation. @type `bool|null` $readonly
Optional. If true, the ability does not modify its environment. @type `bool|null`
$destructive Optional. If true, the ability may perform destructive updates to its
environment. If false, the ability performs only additive updates. @type `bool|null`
$idempotent Optional. If true, calling the ability repeatedly with the same arguments
will have no additional effect on its environment. } @type bool $show_in_rest Optional.
Whether to expose this ability in the REST API. Default false. } @type string $ability_class
Optional. Custom class to instantiate instead of [WP_Ability](https://developer.wordpress.org/reference/classes/wp_ability/).}

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#return)󠁿

 [WP_Ability](https://developer.wordpress.org/reference/classes/wp_ability/)|null
The registered ability instance on success, null on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#source)󠁿

    ```php
    public function register( string $name, array $args ): ?WP_Ability {
    	if ( ! preg_match( '/^[a-z0-9-]+\/[a-z0-9-]+$/', $name ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__(
    				'Ability name must be a string containing a namespace prefix, i.e. "my-plugin/my-ability". It can only contain lowercase alphanumeric characters, dashes and the forward slash.'
    			),
    			'6.9.0'
    		);
    		return null;
    	}

    	if ( $this->is_registered( $name ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			/* translators: %s: Ability name. */
    			sprintf( __( 'Ability "%s" is already registered.' ), esc_html( $name ) ),
    			'6.9.0'
    		);
    		return null;
    	}

    	/**
    	 * Filters the ability arguments before they are validated and used to instantiate the ability.
    	 *
    	 * @since 6.9.0
    	 *
    	 * @param array<string, mixed> $args {
    	 *     An associative array of arguments for the ability.
    	 *
    	 *     @type string               $label                 The human-readable label for the ability.
    	 *     @type string               $description           A detailed description of what the ability does.
    	 *     @type string               $category              The ability category slug this ability belongs to.
    	 *     @type callable             $execute_callback      A callback function to execute when the ability is invoked.
    	 *                                                       Receives optional mixed input and returns mixed result or WP_Error.
    	 *     @type callable             $permission_callback   A callback function to check permissions before execution.
    	 *                                                       Receives optional mixed input and returns bool or WP_Error.
    	 *     @type array<string, mixed> $input_schema          Optional. JSON Schema definition for the ability's input.
    	 *     @type array<string, mixed> $output_schema         Optional. JSON Schema definition for the ability's output.
    	 *     @type array<string, mixed> $meta                  {
    	 *         Optional. Additional metadata for the ability.
    	 *
    	 *         @type array<string, bool|string> $annotations  Optional. Annotation metadata for the ability.
    	 *         @type bool                       $show_in_rest Optional. Whether to expose this ability in the REST API. Default false.
    	 *     }
    	 *     @type string               $ability_class         Optional. Custom class to instantiate instead of WP_Ability.
    	 * }
    	 * @param string               $name The name of the ability, with its namespace.
    	 */
    	$args = apply_filters( 'wp_register_ability_args', $args, $name );

    	// Validate ability category exists if provided (will be validated as required in WP_Ability).
    	if ( isset( $args['category'] ) ) {
    		if ( ! wp_has_ability_category( $args['category'] ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				sprintf(
    					/* translators: %1$s: ability category slug, %2$s: ability name */
    					__( 'Ability category "%1$s" is not registered. Please register the ability category before assigning it to ability "%2$s".' ),
    					esc_html( $args['category'] ),
    					esc_html( $name )
    				),
    				'6.9.0'
    			);
    			return null;
    		}
    	}

    	// The class is only used to instantiate the ability, and is not a property of the ability itself.
    	if ( isset( $args['ability_class'] ) && ! is_a( $args['ability_class'], WP_Ability::class, true ) ) {
    		_doing_it_wrong(
    			__METHOD__,
    			__( 'The ability args should provide a valid `ability_class` that extends WP_Ability.' ),
    			'6.9.0'
    		);
    		return null;
    	}

    	/** @var class-string<WP_Ability> */
    	$ability_class = $args['ability_class'] ?? WP_Ability::class;
    	unset( $args['ability_class'] );

    	try {
    		// WP_Ability::prepare_properties() will throw an exception if the properties are invalid.
    		$ability = new $ability_class( $name, $args );
    	} catch ( InvalidArgumentException $e ) {
    		_doing_it_wrong(
    			__METHOD__,
    			$e->getMessage(),
    			'6.9.0'
    		);
    		return null;
    	}

    	$this->registered_abilities[ $name ] = $ability;
    	return $ability;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/abilities-api/class-wp-abilities-registry.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/abilities-api/class-wp-abilities-registry.php#L80)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/abilities-api/class-wp-abilities-registry.php#L80-L176)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_register_ability_args’, array<string, , string $name )](https://developer.wordpress.org/reference/hooks/wp_register_ability_args/)

Filters the ability arguments before they are validated and used to instantiate 
the ability.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_has_ability_category()](https://developer.wordpress.org/reference/functions/wp_has_ability_category/)`wp-includes/abilities-api.php` |

Checks if an ability category is registered.

  | 
| [WP_Abilities_Registry::is_registered()](https://developer.wordpress.org/reference/classes/wp_abilities_registry/is_registered/)`wp-includes/abilities-api/class-wp-abilities-registry.php` |

Checks if an ability is registered.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [_doing_it_wrong()](https://developer.wordpress.org/reference/functions/_doing_it_wrong/)`wp-includes/functions.php` |

Marks something as being incorrectly called.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 4 more](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_abilities_registry/register/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_abilities_registry%2Fregister%2F)
before being able to contribute a note or feedback.