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

WBOY
Freigeben: 2016-07-12 08:57:49
Original
959 Leute haben es durchsucht

详解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;>
Nach dem Login kopieren

【函数参数】

$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;> 
Nach dem Login kopieren

【参数介绍】

$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;>
Nach dem Login kopieren

【源文件】

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函数解析

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1106883.htmlTechArticle详解WordPress中用于更新和获取用户选项数据的PHP函数,wordpressphp update_user_option()函数 update_user_option()函数作用利用全局博客权限更新用户选...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!