Using WordPress ‘remove_option_whitelist()’ PHP function

The remove_option_whitelist() WordPress PHP function removes a list of options from the allowed options list.

Usage

remove_option_whitelist($del_options, $options = '');

Parameters

  • $del_options (array) – Required. An array of options to be removed from the allowed options list.
  • $options (string|array) – Optional. Default: ”. The list of allowed options, either as a string or an array.

More information

See WordPress Developer Resources: remove_option_whitelist()

Examples

Remove single option from the whitelist

In this example, we will remove a single option named ‘custom_option’ from the allowed options list.

// Removing 'custom_option' from the allowed options list
$del_options = array('custom_option');
remove_option_whitelist($del_options);

Remove multiple options from the whitelist

In this example, we will remove two options named ‘custom_option1’ and ‘custom_option2’ from the allowed options list.

// Removing 'custom_option1' and 'custom_option2' from the allowed options list
$del_options = array('custom_option1', 'custom_option2');
remove_option_whitelist($del_options);

Remove option from a specific options list

In this example, we will remove ‘custom_option’ from a specific list of allowed options.

// Defining a specific list of allowed options
$options = array('option1', 'option2', 'custom_option');

// Removing 'custom_option' from the specific allowed options list
$del_options = array('custom_option');
remove_option_whitelist($del_options, $options);

Remove multiple options from a specific options list

In this example, we will remove ‘custom_option1’ and ‘custom_option2’ from a specific list of allowed options.

// Defining a specific list of allowed options
$options = array('option1', 'option2', 'custom_option1', 'custom_option2');

// Removing 'custom_option1' and 'custom_option2' from the specific allowed options list
$del_options = array('custom_option1', 'custom_option2');
remove_option_whitelist($del_options, $options);

Remove option using string format

In this example, we will remove ‘custom_option’ from the allowed options list using a string format.

// Removing 'custom_option' from the allowed options list using string format
$del_options = 'custom_option';
remove_option_whitelist($del_options);