rest_pre_update_setting
Filters whether to preempt a setting value update via the REST API.
Allows hijacking the setting update logic and overriding the built-in behavior by returning true.
Usage
add_filter( 'rest_pre_update_setting', 'wp_kama_rest_pre_update_setting_filter', 10, 4 );
/**
* Function for `rest_pre_update_setting` filter-hook.
*
* @param bool $result Whether to override the default behavior for updating the value of a setting.
* @param string $name Setting name (as shown in REST API responses).
* @param mixed $value Updated setting value.
* @param array $args Arguments passed to register_setting() for this setting.
*
* @return bool
*/
function wp_kama_rest_pre_update_setting_filter( $result, $name, $value, $args ){
// filter...
return $result;
}
- $result(true|false)
- Whether to override the default behavior for updating the value of a setting.
- $name(string)
- Setting name (as shown in REST API responses).
- $value(mixed)
- Updated setting value.
- $args(array)
- Arguments passed to register_setting() for this setting.
Changelog
| Since 4.7.0 | Introduced. |
Where the hook is called
rest_pre_update_setting
wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php 169
$updated = apply_filters( 'rest_pre_update_setting', false, $name, $request[ $name ], $args );