wp_set_all_user_settings()
Private. Sets all user interface settings.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
true|false|null
. True if set successfully, false if the current user could not be found. Null if the current user is not a member of the site.
Usage
wp_set_all_user_settings( $user_settings );
- $user_settings(array) (required)
- User settings.
Notes
- Global. Array. $_updated_user_settings
Changelog
Since 2.8.0 | Introduced. |
wp_set_all_user_settings() wp set all user settings code WP 6.6.2
function wp_set_all_user_settings( $user_settings ) { global $_updated_user_settings; $user_id = get_current_user_id(); if ( ! $user_id ) { return false; } if ( ! is_user_member_of_blog() ) { return; } $settings = ''; foreach ( $user_settings as $name => $value ) { $_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name ); $_value = preg_replace( '/[^A-Za-z0-9_-]+/', '', $value ); if ( ! empty( $_name ) ) { $settings .= $_name . '=' . $_value . '&'; } } $settings = rtrim( $settings, '&' ); parse_str( $settings, $_updated_user_settings ); update_user_option( $user_id, 'user-settings', $settings, false ); update_user_option( $user_id, 'user-settings-time', time(), false ); return true; }