How to display logged in users comments (only) on Wordpress

后端 未结 1 1983
野趣味
野趣味 2021-01-03 14:18

I\'m currently building a niche Q+A site using wordpress with which users can either log in and post questions or log in and answer questions.

Questions are currentl

1条回答
  •  隐瞒了意图╮
    2021-01-03 14:42

    1. Click on Settings > Discussions and set what you want from there. There is one option that lets only registered members to post a comment.
    2. http://pastebin.com/EJcghXAW - see code from line #39, same aproach also in your case.

    The query for the comments is the normal wordpress way, but you need to include it in the conditionals linked and pointed above.

    Usage example:

     'approve',
            'order' =>  'DESC',
            'user_id' => $user_id
        );
        $comments = get_comments($args);
        foreach($comments as $comment) :
            echo '

    '; echo($comment->comment_author . '
    ' . $comment->comment_content); echo '

    '; endforeach; } ?>

    0 讨论(0)
提交回复
热议问题