Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/update user option


Update a user option that can be either per Site or per Network.

User options are just like user metadata except that they have support for blog-specific options when using multisite. If the $global parameter is false, which it is by default, it will prepend the WordPress table prefix to the option name.


<?php update_user_option$user_id$option_name$newvalue$global ?>


(integer) (required) User ID
Default: None
(string) (required) User option name.
Default: None
(mixed) (required) User option value.
Default: None
(boolean) (optional) Whether option name is blog specific or not.
Default: false

Return Values

Whether the update was successful


Hide the admin bar for a user on the front end of the site:

update_user_option( $user_id, 'show_admin_bar_front', false );

When multisite is installed, the $global parameter can be used to set the user option for the whole network, instead of just the current site:

update_user_option( $user_id, 'show_admin_bar_front', false, true );


  • Uses global: (object) $wpdb WordPress database object for queries.

Change Log

Source File

update_user_option() is located in wp-includes/user.php.


add_user_meta(), delete_user_meta(), get_user_meta(), update_user_meta(), get_user_option(), delete_user_option(), update_user_option(),

See also index of Function Reference and index of Template Tags.