2010-09-30 69 views
0

在Wordpress中,我希望當作者閱讀他的帖子顯示文本,如'刪除帖子,編輯帖子,....等'的職位只爲作者不適合所有用戶如何才能在文章中顯示文本只爲作者

第一:我想知道用戶登錄的ID 二:我想知道作者的ID .. 然後:

if($user_id_login == $id_author){ 
echo 'Delete Post , Edit Post ... etc'; 
} 

但是從哪裏獲得的$user_id_login$id_author values?

回答

2

事情是這樣的:

if (is_user_logged_in()){ 
    global $current_user; 
    get_currentuserinfo(); 
    if($current_user->ID == $post->post_author){ 
     echo "<a href='#'>edit</a>"; 
    } 
} 
+0

哇偉大的..這是正確的..非常感謝你.. – AboSami 2010-09-30 06:25:15

+1

那裏,你又忘了接受的答案 – ariefbayu 2010-10-01 01:38:00

+0

哦,對不起,我不知道這以前..非常感謝你..我接受你的回答^ _^.. – AboSami 2010-10-03 18:53:57