PHP functions used to update and retrieve user option data in WordPress

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.