簡體   English   中英

如何在wordpress中基於登錄用戶添加條件?

[英]How to add condition based on logged in user in wordpress?

我需要一些幫助來顯示特定用戶的特定內容。 期望類似於以下內容

if( is_username('john')
{
  $echo 'Welcome john. You are from india.';
} else {
  $echo 'You have no rights to access this page...';
}

它應該僅通過用戶名(文本)而不是通過user_id或任何整數來檢查條件。 可能??

使用get_currentuserinfo(),然后將$current_user->user_login與要檢查的用戶名進行比較。

例如:

get_currentuserinfo()
if($current_user->user_login == 'the_username') {
    echo 'woop';
} else {
    echo 'nope';
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM