set-screen-option filter-hookWP 2.8.0

Filters a screen option value before it is set.

The filter can also be used to modify non-standard [items]_per_page settings. See the parent function for a full list of standard options.

Returning false from the filter will skip saving the current option.


add_filter( 'set-screen-option', 'wp_kama_set_screen_option_filter', 10, 3 );

 * Function for `set-screen-option` filter-hook.
 * @param mixed  $screen_option The value to save instead of the option value.
 * @param string $option        The option name.
 * @param int    $value         The option value.
 * @return mixed
function wp_kama_set_screen_option_filter( $screen_option, $option, $value ){

	// filter...
	return $screen_option;
The value to save instead of the option value.
Default: false (to skip saving the current option)
The option name.
The option value.


Since 2.8.0 Introduced.
Since 5.4.2 Only applied to options ending with '_page', or the 'layout_columns' option.

Where the hook is called

wp-admin/includes/misc.php 773
$screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores

Where the hook is used in WordPress

Usage not found.