Filter hook 'set_screen_option_{$option}'

in WP Core File wp-admin/includes/misc.php at line 792

View Source

set_screen_option_{$option}

Filter Hook
Description
Filters a screen option value before it is set. The dynamic portion of the hook name, `$option`, refers to the option name. Returning false from the filter will skip saving the current option.

Hook Information

File Location wp-admin/includes/misc.php View on GitHub
Hook Type Filter
Line Number 792

Hook Parameters

Type Name Description
mixed $screen_option The value to save instead of the option value. Default false (to skip saving the current option).
string $option The option name.
int $value The option value.

Usage Examples

Basic Usage
<?php
// Hook into set_screen_option_{$option}
add_filter('set_screen_option_{$option}', 'my_custom_filter', 10, 3);

function my_custom_filter($screen_option, $option, $value) {
    // Your custom filtering logic here
    return $screen_option;
}

Source Code Context

wp-admin/includes/misc.php:792 - How this hook is used in WordPress core
<?php
 787  			 * @param mixed   $screen_option The value to save instead of the option value.
 788  			 *                               Default false (to skip saving the current option).
 789  			 * @param string  $option        The option name.
 790  			 * @param int     $value         The option value.
 791  			 */
 792  			$value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
 793  
 794  			if ( false === $value ) {
 795  				return;
 796  			}
 797  

PHP Documentation

<?php
/**
			 * Filters a screen option value before it is set.
			 *
			 * The dynamic portion of the hook name, `$option`, refers to the option name.
			 *
			 * Returning false from the filter will skip saving the current option.
			 *
			 * @since 5.4.2
			 *
			 * @see set_screen_options()
			 *
			 * @param mixed   $screen_option The value to save instead of the option value.
			 *                               Default false (to skip saving the current option).
			 * @param string  $option        The option name.
			 * @param int     $value         The option value.
			 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-admin/includes/misc.php
Related Hooks

Related hooks will be displayed here in future updates.