delete_user_setting

Delete user interface settings.

Description

(bool|null) delete_user_setting( (string) $names ); 

Deleting settings would reset them to the defaults.

This function has to be used before any output has started as it calls setcookie().

Returns (bool|null)

True if deleted successfully, false if not. Null if the current user can't be established.

Parameters (1)

0. $names (string)
The name or array of names of the setting to be deleted.

Usage

  1. if ( !function_exists( 'delete_user_setting' ) ) { 
  2. require_once ABSPATH . WPINC . '/option.php'; 
  3.  
  4. // The name or array of names of the setting to be deleted. 
  5. $names = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = delete_user_setting($names); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/option.php  
  1. function delete_user_setting( $names ) { 
  2. if ( headers_sent() ) { 
  3. return false; 
  4.  
  5. $all_user_settings = get_all_user_settings(); 
  6. $names = (array) $names; 
  7. $deleted = false; 
  8.  
  9. foreach ( $names as $name ) { 
  10. if ( isset( $all_user_settings[$name] ) ) { 
  11. unset( $all_user_settings[$name] ); 
  12. $deleted = true; 
  13.  
  14. if ( $deleted ) { 
  15. return wp_set_all_user_settings( $all_user_settings ); 
  16.  
  17. return false;