search
Homephp教程php手册详解WordPress中用于更新和获取用户选项数据的PHP函数,wordpressphp

详解WordPress中用于更新和获取用户选项数据的PHP函数,wordpressphp

update_user_option()函数

update_user_option()函数作用利用全局博客权限更新用户选项。
用户选项类似于用户元数据,唯一的不同之处在于用户选项支持全局博客选项。如果'global'参数为False(默认情况下),update_user_option会预先将WordPress表前缀改成选项名称。

【函数使用】

<&#63;php update_user_option( $user_id, $option_name, $newvalue, $global ) &#63;>

【函数参数】

$user_id
(整数)(必需)用户ID
默认值:None
$option_name
(字符串)(必需)用户选项名称
默认值:0
$newvalue
(混合)(必需)用户选项值
默认值:None
$global
(布尔值)(可选)选项名称是否博客特有
默认值:false

【返回值】

(boolean)
成功返回True,失败返回False

【源文件】

update_user_option())位于 wp-includes/user.php中。

wordpress get_user_option()函数

get_user_option()函数
【函数介绍】

检索用户选项,包括global、user或blog。
如果未给出用户ID,使用当前用户ID。如果给出用户ID,检索该用户相关数据。函数结果的过滤器将原始选项名称和最终用户数据库对象作为第三个参数传递。
该选项函数首先查找非全局名称,然后查找全局名称,如果仍然没有找到,函数会查找博客选项。可通过插件设置或修改选项。

【函数用法】

<&#63;php get_user_option( $option, $user, $check_blog_options ) &#63;> 

【参数介绍】

$option
(字符串)(必需)用户选项名称
默认值:None
$user
(整数)(可选)用户ID
默认值:0
$check_blog_options
(布尔值)(可选)如果之前的用户选项不存在,是否需要在选项表中查找一个选项
默认值:true

【返回值】

(混合)
成功返回选项的值,失败返回FALSE

【函数实例】

<&#63;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';
 }
&#63;>

【源文件】

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


您可能感兴趣的文章:

  • 解析WordPress中控制用户登陆和判断用户登陆的PHP函数
  • 编写PHP脚本清除WordPress头部冗余代码的方法讲解
  • WordPress主题制作中自定义头部的相关PHP函数解析
  • WordPress中调试缩略图的相关PHP函数使用解析
  • WordPress开发中自定义菜单的相关PHP函数使用简介
  • WordPress中用于获取搜索表单的PHP函数使用解析
  • 详解WordPress中创建和添加过滤器的相关PHP函数
  • WordPress中用于创建以及获取侧边栏的PHP函数讲解
  • 讲解WordPress中用于获取评论模板和搜索表单的PHP函数
  • WordPress中编写自定义存储字段的相关PHP函数解析
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.