The update_user_option () function update_user_option () Updates user options using the Global blog permission. User options are similar to user metadata. The only difference is that user options support global blog options. If the global parameter is False (by default), update_user_option changes the prefix of the WordPress table
The update_user_option () function update_user_option () Updates user options using the Global blog permission. User options are similar to user metadata. The only difference is that user options support global blog options. If the 'global' parameter is False (by default), update_user_option changes the prefix of the WordPress table
Update_user_option () function
The update_user_option () function uses the Global blog permission to update user options.
User options are similar to user metadata. The only difference is that user options support global blog options. If the 'global' parameter is False (by default), update_user_option changes the prefix of the WordPress table to the option name in advance.
[Function usage]
<?php update_user_option( $user_id, $option_name, $newvalue, $global ) ?>
[Function parameters]
$ User_id
(Integer) (required) User ID
Default Value: None
$ Option_name
(String) (required) user option name
Default Value: 0
$ Newvalue
(Mixed) (required) user option value
Default Value: None
$ Global
(Boolean) (optional) whether the option name is blog-specific
Default Value: false
[Return value]
(Boolean)
Returns True if the call is successful, and False if the call fails.
[Source file]
Update_user_option () is located in wp-uplodes/user. php.
Wordpress get_user_option () function
Get_user_option () function
[Function Introduction]
Search user options, including global, user, or blog.
If no user ID is provided, use the current user ID. If a user ID is provided, the user-related data is retrieved. The filter of the function result passes the original option name and the end user database object as the third parameter.
This option function first looks for a non-Global name, and then finds the global name. If it still does not, the function looks for the blog option. You can set or modify options through the plug-in.
[Function usage]
<?php get_user_option( $option, $user, $check_blog_options ) ?>
[Parameter description]
$ Option
(String) (required) user option name
Default Value: None
$ User
(Integer) (optional) User ID
Default Value: 0
$ Check_blog_options
(Boolean) (optional) if the previous user option does not exist, do you need to find an option in the option table?
Default Value: true
[Return value]
(Hybrid)
The value of the option is returned. If the option fails, FALSE is returned.
Function instance]
<?php $bar = get_user_option( 'show_admin_bar_front', get_current_user_id() ); if( $bar == 'true' ) { echo 'The admin bar is enabled'; } else { echo 'The admin bar is disabled'; }?>
[Source file]
Get_user_option () is located in wp-includes/user. php.