0

I want to create a profile page and display the logged in persons comments, AND also responses to his/her comment.

Like this:

Post title

Comment (by logged in user)

--->Responses(replies) to his/her comment

Any ideas how to do this?

EDIT:

This is what I got right now, I get the logged in persons comments with use of a shortcode on a page that I have.

What I want to get is also the responses for each comment made by this logged in user.

<?php
/*
Plugin Name: Show Recent Comments by a particular user
Plugin URI: http://blog.ashfame.com/?p=876
Description: Provides a shortcode which you can use to show recent comments by a particular user
Author: Ashfame
Author URI: http://blog.ashfame.com/
License: GPL
Usage: 
*/

add_shortcode ( 'show_recent_comments', 'show_recent_comments_handler' );

function show_recent_comments_handler( $atts, $content = null )
{
    extract( shortcode_atts( array( 
        "count" => 10,
        "pretty_permalink" => 0
        ), $atts ));

    $output = ''; // this holds the output

    if ( is_user_logged_in() )
    {
        global $current_user;
        get_currentuserinfo();

        $args = array(
            'user_id' => $current_user->ID,
            'number' => $count, // how many comments to retrieve
            'status' => 'approve'
            );

        $comments = get_comments( $args );
        if ( $comments )
        {
            $output.= "<ul>\n";
            foreach ( $comments as $c )
            {
            $output.= '<li>';
            if ( $pretty_permalink ) // uses a lot more queries (not recommended)
                $output.= '<a href="'.get_comment_link( $c->comment_ID ).'">';
            else
                $output.= '<a href="'.get_settings('siteurl').'/?p='.$c->comment_post_ID.'#comment-'.$c->comment_ID.'">';           
            $output.= $c->comment_content;
            $output.= '</a>';
            $output.= "</li>\n";
            }
            $output.= '</ul>';
        }
    }
    else
    {
        $output.= "<h2>You should be logged in to see your comments. Make sense?</h2>";
        $output.= '<h2><a href="'.get_settings('siteurl').'/wp-login.php?redirect_to='.get_permalink().'">Login Now &rarr;</a></h2>';
    }
    return $output;
}
?>
  • A) What about comments by the author that were just a reply? If you don't list them, it would be incomplete. If you list them without any parents, you'd drag things out of context and possibly kill any meaning behind a discussion. B) Where's your research? What did you try? This is no trivial task and so far it's a "do this job for me"-request and not a question that can really be guided or helped on, but just being written and solved for you for free. – kaiser May 22 '13 at 11:04
  • A) This is not a discussion modul, I know what I want :) so dont you be worried about that. I just want it that way I want it. b) My research gave me this link and that works fine, I only need to display responses (_only_responses to the logged in users comment). And no, its not a "do this job for me". Im not a hard core coder so I ask for help. Im sorry for asking help if this is what people feel.. – mackanL May 22 '13 at 12:15
  • Ad B) Then please edit your question and add any info that you already researched. Will get people who are willing to help much faster on track and shows that you don't use this site as search engine replacement. – kaiser May 22 '13 at 13:51
0

Any ideas anyone?

Ive tried to run same array and foreach but for user_id => 1, to test. But all I get is a complete list with comments made by user with id 1.

I want to display only the responses (from user id 1) below the current_user comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.