欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解WordPress中用于更新和獲取用戶選項(xiàng)數(shù)據(jù)的PHP函數(shù)

 更新時(shí)間:2016年03月08日 14:29:58   作者:TIANQIXIN  
這篇文章主要介紹了WordPress中用于更新和獲取用戶選項(xiàng)數(shù)據(jù)的PHP函數(shù),分別為對(duì)update_user_option()函數(shù)和get_user_option()函數(shù)用法的講解,需要的朋友可以參考下

update_user_option()函數(shù)

update_user_option()函數(shù)作用利用全局博客權(quán)限更新用戶選項(xiàng)。
用戶選項(xiàng)類似于用戶元數(shù)據(jù),唯一的不同之處在于用戶選項(xiàng)支持全局博客選項(xiàng)。如果'global'參數(shù)為False(默認(rèn)情況下),update_user_option會(huì)預(yù)先將WordPress表前綴改成選項(xiàng)名稱。

【函數(shù)使用】

<?php update_user_option( $user_id, $option_name, $newvalue, $global ) ?>

【函數(shù)參數(shù)】

$user_id
(整數(shù))(必需)用戶ID
默認(rèn)值:None
$option_name
(字符串)(必需)用戶選項(xiàng)名稱
默認(rèn)值:0
$newvalue
(混合)(必需)用戶選項(xiàng)值
默認(rèn)值:None
$global
(布爾值)(可選)選項(xiàng)名稱是否博客特有
默認(rèn)值:false

【返回值】

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

【源文件】

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

wordpress get_user_option()函數(shù)

get_user_option()函數(shù)
【函數(shù)介紹】

檢索用戶選項(xiàng),包括global、user或blog。
如果未給出用戶ID,使用當(dāng)前用戶ID。如果給出用戶ID,檢索該用戶相關(guān)數(shù)據(jù)。函數(shù)結(jié)果的過(guò)濾器將原始選項(xiàng)名稱和最終用戶數(shù)據(jù)庫(kù)對(duì)象作為第三個(gè)參數(shù)傳遞。
該選項(xiàng)函數(shù)首先查找非全局名稱,然后查找全局名稱,如果仍然沒(méi)有找到,函數(shù)會(huì)查找博客選項(xiàng)??赏ㄟ^(guò)插件設(shè)置或修改選項(xiàng)。

【函數(shù)用法】

<?php get_user_option( $option, $user, $check_blog_options ) ?> 

【參數(shù)介紹】

$option
(字符串)(必需)用戶選項(xiàng)名稱
默認(rèn)值:None
$user
(整數(shù))(可選)用戶ID
默認(rèn)值:0
$check_blog_options
(布爾值)(可選)如果之前的用戶選項(xiàng)不存在,是否需要在選項(xiàng)表中查找一個(gè)選項(xiàng)
默認(rèn)值:true

【返回值】

(混合)
成功返回選項(xiàng)的值,失敗返回FALSE

【函數(shù)實(shí)例】

<?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';
 }
?>

【源文件】

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


相關(guān)文章

最新評(píng)論