开发者

How can showing text in a post only for the author

开发者 https://www.devze.com 2023-01-18 17:01 出处:网络
In Wordpress , I w开发者_StackOverflow中文版ant when the author of the post reading his post showing text like\' Delete Post , Edit Post , .... etc\" only for the author not for all users.

In Wordpress , I w开发者_StackOverflow中文版ant when the author of the post reading his post showing text like' Delete Post , Edit Post , .... etc" only for the author not for all users.

First: I want to know the id of user login Second: I want to know the id of author .. Then:

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

but from where do I get the $user_id_login and $id_author values?


Something like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消