Codex

Function Reference/delete option

Contents

Description

A safe way of removing a named option/value pair from the options database table.

Usage

<?php delete_option($name); ?>

Example

A simple way to delete one or multiple options at once and also to verify the result:

<?php
function deleteOptions()
{
	$args = func_get_args();
	$num = count($args);

	if ($num == 1) {
		return (delete_option($args[0]) ? TRUE : FALSE);
	}
	elseif (count($args) > 1)
	{
		foreach ($args as $option) {
			if ( ! delete_option($option))
				return FALSE;
		}
		return TRUE;
	}
	return FALSE;
}

if (deleteOptions('is_installed', 'my_plugin_version', 'my_option'))
   echo 'Options have been deleted!';
else
   echo 'An error has occurred while trying to delete the options from database!';
?>


Usage

<?php delete_option("myhack_extraction_length"); ?>

Parameters

$name
(string) (required) Name of the option to be deleted. A list of valid default options can be found at the Option Reference.
Default: None

Return value

Boolean TRUE if the option has been successfully deleted, otherwise FALSE

Related

get_option, add_option, update_option, delete_option

See also index of Function Reference and index of Template Tags.
This article is marked as in need of editing. You can help Codex by editing it.