wp_set_all_user_settings

Private.

Description

(bool|null) wp_set_all_user_settings( (array) $user_settings ); 

Set all user interface settings.

Returns (bool|null)

False if the current user can't be found, null if the current user is not a super admin or a member of the site, otherwise true.

Parameters (1)

0. $user_settings (array)
The user settings.

Usage

  1. if ( !function_exists( 'wp_set_all_user_settings' ) ) { 
  2. require_once ABSPATH . WPINC . '/option.php'; 
  3.  
  4. // The user settings. 
  5. $user_settings = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_set_all_user_settings($user_settings); 
  9.  

Defined (1)

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

/wp-includes/option.php  
  1. function wp_set_all_user_settings( $user_settings ) { 
  2. global $_updated_user_settings; 
  3.  
  4. if ( ! $user_id = get_current_user_id() ) { 
  5. return false; 
  6.  
  7. return; 
  8.  
  9. $settings = ''; 
  10. foreach ( $user_settings as $name => $value ) { 
  11. $_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name ); 
  12. $_value = preg_replace( '/[^A-Za-z0-9_-]+/', '', $value ); 
  13.  
  14. if ( ! empty( $_name ) ) { 
  15. $settings .= $_name . '=' . $_value . '&'; 
  16.  
  17. $settings = rtrim( $settings, '&' ); 
  18. parse_str( $settings, $_updated_user_settings ); 
  19.  
  20. update_user_option( $user_id, 'user-settings', $settings, false ); 
  21. update_user_option( $user_id, 'user-settings-time', time(), false ); 
  22.  
  23. return true;