Codex tools: Log in / create account
Contents |
A safe way of removing a named option/value pair from the options database table.
<?php delete_option($name); ?>
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!';
?>
<?php delete_option("myhack_extraction_length"); ?>
Boolean TRUE if the option has been successfully deleted, otherwise FALSE
get_option, add_option, update_option, delete_option