Support » Fixing WordPress » Displaying User Profile Descriptions In Comments

  • I’ll apologize if there is a section which explains this but I’ve searched the forum as well as the codex and haven’t found the answer. If it exists already I’d greatly appreciate it that you (whomever you are nice person) points me in the correct direction.

    I’m aware there is a template tag that displays the profile description (aka the profile area in Profile) for the author. But what I haven’t seen, and what I’m trying to find, is a template tag/hack/or work-a-round that will display the profile description for users. What I’m trying to do is have each profile description display for each commenter. Thanks for your assistance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • This is fairly easy as comments *typically* retain a user ID for registered, logged in users. What I’d suggest, before the comment loop starts in comments.php, is to perform a query on user descriptions and assign them to an array, using the IDs as keys (I’ll use $desc for the example):

    $profiles = $wpdb->get_results("SELECT ID, user_description FROM $wpdb->users");
    foreach($profiles as $profile) {
    $desc[$profile->ID] = $profile->user_description;

    Then in the comment loop, where you want to display the description:

    <?php echo $desc[$comment->user_id]; ?>

    Tight! I appreciate the help. Your example worked just like I wanted!

    That’s great, thanks Kafkaesqui. Is there anyway to make the description appear in a new page rather than in the comments section?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Displaying User Profile Descriptions In Comments’ is closed to new replies.