Title: WP_REST_Abilities_V1_Run_Controller::sanitize_input_for_ability
Published: August 20, 2026

---

# WP_REST_Abilities_V1_Run_Controller::sanitize_input_for_ability( mixed $input, WP_REST_Request $request ): mixed

## In this article

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

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

Sanitizes the run input by coercing it to the ability’s input schema.

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

Registered as the `input` argument `sanitize_callback` so that both `check_ability_permissions()`
and `execute_ability()` receive natively typed input regardless of transport.

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

 * [WP_REST_Abilities_V1_Run_Controller::coerce_input_to_schema()](https://developer.wordpress.org/reference/classes/WP_REST_Abilities_V1_Run_Controller/coerce_input_to_schema/)

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

 `$input`mixedrequired

Raw input extracted from the request.

`$request`[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)
required

The request object.

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

 mixed Coerced input, or the raw input when it cannot be safely coerced.

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

    ```php
    public function sanitize_input_for_ability( $input, $request ) {
    	$ability = wp_has_ability( $request['name'] ) ? wp_get_ability( $request['name'] ) : null;
    	if ( ! $ability instanceof WP_Ability ) {
    		return $input;
    	}

    	return $this->coerce_input_to_schema( $input, $ability );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php#L241)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php#L241-L248)

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

| Uses | Description | 
| [WP_REST_Abilities_V1_Run_Controller::coerce_input_to_schema()](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/coerce_input_to_schema/)`wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php` |

Coerces raw request input to the types declared in the ability input schema.

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

Checks if an ability is registered.

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

Retrieves a registered ability.

  |

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

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

## User Contributed Notes

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