Using WordPress ‘remove_option_update_handler()’ PHP function

The remove_option_update_handler() WordPress PHP function unregisters a setting.

Usage

remove_option_update_handler('option_group', 'option_name');

Parameters

  • $option_group (string): The settings group name used during registration.
  • $option_name (string): The name of the option to unregister.
  • $sanitize_callback (callable, optional): Deprecated, default is an empty string.

More information

See WordPress Developer Resources: remove_option_update_handler

_Deprecated: This function is deprecated, consider using unregister_setting() instead._

Examples

Unregister a basic setting

Unregister the setting ‘my_option_name’ in the group ‘my_settings_group’:

remove_option_update_handler('my_settings_group', 'my_option_name');

Unregister a setting in a custom settings group

Unregister the setting ‘custom_option_name’ in the group ‘custom_settings_group’:

remove_option_update_handler('custom_settings_group', 'custom_option_name');

Unregister a setting with a deprecated sanitize callback

Unregister the setting ‘deprecated_option_name’ in the group ‘deprecated_settings_group’ with a deprecated sanitize callback:

remove_option_update_handler('deprecated_settings_group', 'deprecated_option_name', 'deprecated_sanitize_callback');

Unregister a setting in a theme options group

Unregister the setting ‘theme_option_name’ in the group ‘theme_options_group’:

remove_option_update_handler('theme_options_group', 'theme_option_name');

Unregister a setting in a plugin options group

Unregister the setting ‘plugin_option_name’ in the group ‘plugin_options_group’:

remove_option_update_handler('plugin_options_group', 'plugin_option_name');