Displaying User Profile Descriptions In Comments (4 posts)

  1. Suppose
    Posted 10 years ago #

    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.

  2. Kafkaesqui

    Posted 10 years ago #

    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]; ?>

  3. Suppose
    Posted 10 years ago #

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

  4. restlessbtvs
    Posted 10 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic