Filter hook 'rest_pre_update_setting'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php at line 169

View Source

rest_pre_update_setting

Filter Hook
Description
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.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php View on GitHub
Hook Type Filter
Line Number 169

Hook Parameters

Type Name Description
bool $result Whether to override the default behavior for updating the value of a setting.
string $name Setting name (as shown in REST API responses).
mixed $value Updated setting value.
array $args Arguments passed to register_setting() for this setting.

Usage Examples

Basic Usage
<?php
// Hook into rest_pre_update_setting
add_filter('rest_pre_update_setting', 'my_custom_filter', 10, 4);

function my_custom_filter($result, $name, $value, $args) {
    // Your custom filtering logic here
    return $result;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php:169 - How this hook is used in WordPress core
<?php
 164  			 *                       value of a setting.
 165  			 * @param string $name   Setting name (as shown in REST API responses).
 166  			 * @param mixed  $value  Updated setting value.
 167  			 * @param array  $args   Arguments passed to register_setting() for this setting.
 168  			 */
 169  			$updated = apply_filters( 'rest_pre_update_setting', false, $name, $request[ $name ], $args );
 170  
 171  			if ( $updated ) {
 172  				continue;
 173  			}
 174  

PHP Documentation

<?php
/**
			 * 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.
			 *
			 * @since 4.7.0
			 *
			 * @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.
			 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php
Related Hooks

Related hooks will be displayed here in future updates.