Forums

Show only comments by specific registered user (10 posts)

  1. jillsays
    Member
    Posted 2 months ago #

    Hi all,
    I'm trying to build some community features into my site, and one of the things I'd like to do on the profile page is show all the last 15 comments by that user, and what thread they were posted in.

    I can't find codex to help me out with this anywhere. If anyone can help me out, I'd be very grateful.

    Thanks-

  2. Shane G
    Member
    Posted 2 months ago #

    Hi,

    Use this plugin:

    http://wordpress.org/extend/plugins/role-scoper/

    Now, you can create your desired role to your blog and assign that to the user for which you want to allow for comments.

    Thanks,

    Shane G.

  3. jillsays
    Member
    Posted 2 months ago #

    Hi,

    Thanks for responding. I'm actually just looking for the codex so I can hard-code it into the user's profile pages.

    I am already using the Alkivia Open Community plugin. As it stands, the codex I'm using only lists the POST TITLE that the user last commented on. I'm trying to figure out how to make it display an excerpt of the comment as well. Here's the code I'm currently using. Does anyone know what I'd need to add/modify to make it show the particular user's last 15 comments --- and the excerpts of the actual comments?

    Thanks:

    function _recentComments( & $user ) {
    		global $wpdb;
    		$data = array();
    
    		$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' AND user_id = '{$user->ID}' GROUP BY comment_post_ID ORDER BY comment_date_gmt DESC LIMIT 0,5");
    		if ( $comments ) {
    		    $data['title'] = __('Latest coments on:', $this->pid);
    		    foreach ( (array) $comments as $comment ) {
    		        $data['content'][] = '<a href="' . clean_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>';
    		    }
    		}
    
    		$user->aoc_widgets['commentlist'] = $data;
    	}
  4. jillsays
    Member
    Posted 2 months ago #

    I still haven't been able to figure this out. Does anyone know the code to display the last, say, 15 comments by a particular registered user?

  5. webmatter
    Member
    Posted 2 months ago #

    Hi, you could try
    get_the_excerpt($comment->comment_post_ID) instead of
    get_the_title($comment->comment_post_ID)
    in your code (or in addtion to get_the_title();) and see if this works .. good luck!

  6. jillsays
    Member
    Posted 2 months ago #

    Thanks for helping. I tried using get_the_excerpt($comment->comment_post_ID) instead of
    get_the_title($comment->comment_post_ID) and it broke the template.

    I am using this code on another site that DOES display the comment excerpts, but it shows comments by all users, not just one particular user. I just can't figure out how to blend the two:

    <?php
    global $wpdb;
    $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
    comment_post_ID, comment_author, comment_date_gmt, comment_approved,
    comment_type,comment_author_url,
    SUBSTRING(comment_content,1,75) AS com_excerpt
    FROM $wpdb->comments
    LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
    $wpdb->posts.ID)
    WHERE comment_approved = '1' AND comment_type = '' AND
    post_password = ''
    ORDER BY comment_date_gmt DESC
    LIMIT 5";
    $comments = $wpdb->get_results($sql);
    $output = $pre_HTML;
    $output .= "\n<ul class=sidebar_list2>";
    foreach ($comments as $comment) {
    $output .= "\n<li>".strip_tags($comment->comment_author)
    .":&nbsp" . "<a href=\"" . get_permalink($comment->ID) .
    "#comment-" . $comment->comment_ID . "\" title=\"on " .
    $comment->post_title . "\">" . strip_tags($comment->com_excerpt)
    ."...</a></li>";
    }
    $output .= "\n</ul>";
    $output .= $post_HTML;
    echo $output;?>
  7. jillsays
    Member
    Posted 2 months ago #

    I clearly don't know a lot about PHP and wordpress codex. And I've been spending multiple hours a day trying to figure this problem out. I've been unsuccessful. I must check this thread about 45 times a day to see if anyone has responded. So can't one of you genius, brilliant, much smarter than I am people take pity on me and help me out? Pretty please?

  8. jillsays
    Member
    Posted 1 month ago #

    Does anyone have any other ideas? It's almost 2 weeks later, and I've still been unable to modify that code to make it display the actual comment text. Thanks.

  9. webmatter
    Member
    Posted 1 month ago #

    Hi, there is a theme 'commentpress' that has this function
    http://www.futureofthebook.org/commentpress/download/
    I just couldn't figure out how to extract it.
    If you succeed kindly let me know ... I am interested in this function, too.

  10. jillsays
    Member
    Posted 1 month ago #

    I still haven't succeeded - and that theme doesn't show comments by a particular user, it shows comments by all users.

    Is this just such a difficult issue - or is it that the people who know the answer just can't be bothered to help?

    Gotta love wordpress "support."

Reply

You must log in to post.

About this Topic

Tags