Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: bbpress info in wordpress?

Kahil, your method works well if your users use their login name as their display name. However if a user who’s login is user23 changes his display name to John Doe then your code looks for this image. /forum/avatars/John Doe.jpg instead of the correct avatar image which would be /forum/avatars/user23.jpg. I couldn’t figure out a clean way to fix this (I’m using wpmu, not wordpress). But here’s a dirty hack.

<?php
$comment_author_dn = get_comment_author();
$comment_author = $wpdb->get_row("SELECT <code>user_login</code> FROM <code>wp_users</code> WHERE <code>display_name</code> = '$comment_author_dn'");
echo '<img id="comment-avatar" height="50" width="50" src="/forums/avatars/' . (empty($comment_author->user_login) ? "default" : $comment_author->user_login) . '" alt="avatar" />';
?>

That code should find images for a user if they use a display name or not.

/shrug

I haven’t fully tested it, but it seems to work ok.

Skip to toolbar