Need a Comments hack (3 posts)

  1. rickyxstar
    Posted 4 years ago #

    I'm creating a site with a social feel to it for a client.
    Users have profiles that uses $_GET to serve up their info.

    So their urls look like this /profile/?userid=1
    the page /profile/ uses a template I created to do this.

    I want to use WordPress's commenting system for the user's comment wall.
    Is there a way to change the loop to find comments for the user's id rather than the page's id which will stay the same on every user's profile?

  2. rickyxstar
    Posted 4 years ago #

    I already found a way to change the hidden input on the comment form's comment_post_ID value to that of the user id in the url

  3. rickyxstar
    Posted 4 years ago #

    Found it!
    If any one else ever has this problem its in line 884 of code in the wp-includes/comments-template.php file

    $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt",$post->ID , $user_ID));

    Change "$post->ID" to "$_GET[userid]"

Topic Closed

This topic has been closed to new replies.

About this Topic