Lampwrights Forum

Lampwrights Forum (http://www.lampwrights.com/index.php)
-   vBulletin Wordpress Bridge (http://www.lampwrights.com/forumdisplay.php?f=13)
-   -   Where are author avatars supposed to appear (http://www.lampwrights.com/showthread.php?t=233)

wacnstac 10-05-2011 08:24 AM

Where are author avatars supposed to appear
 
I see code in the vbbridge.php file that is supposed to do something with avatars, but I don't see any on any of the WP pages or in the comments. Am I missing something?

Jeff 10-06-2011 09:53 AM

Do your templates use the get_avatar() function at all?

wacnstac 10-06-2011 10:20 AM

Yes, I have called it from a template. It is also called somewhere in the commenting engine but I can't figure out where (I know it is being called for every comment posted because of my debug logs). I used Firephp to do some debugging on it. The code is expecting an integer for $u->user_id in your code but never getting one so if (!is_numeric($u->user_id)) { return; } is always returning.

wacnstac 10-06-2011 11:38 AM

Also it would help out a ton if I new what the function get_avatar was expecting in the $u parameter.

Jeff 10-07-2011 06:14 AM

$u is the user object. You pass that along to it..

wacnstac 10-07-2011 08:50 AM

I ended up modifying the get_avatar function with the following so I could pass in a user's vb id and get it to work correctly:

PHP Code:

function get_post_avatar($u$size '96'$default ''$alt false )
{
    global 
$vb;
    global 
$firephp;
    
    
/*    if (!is_numeric($u->user_id)) { return; }  */ 
    
if (!is_numeric($u['userid'])) { return; }    

/*    $user = fetch_userinfo($u->user_id);  */ 
    
$user fetch_userinfo($u['userid']);

    if (
$avatar $vb->db->query_first("SELECT dateline, width, height FROM " TABLE_PREFIX "customavatar WHERE userid=" intval($user['userid'])))
    {
        
$safe_alt esc_attr($user['username']);

        
// using a custom avatar
        
if ($vb->options['usefileavatar'])
        {
            
$user['avatarurl'] = $vb->options['avatarurl'] . '/avatar' $user['userid'] . '_' $user['avatarrevision'] . '.gif';
        }

        else
        {
            
$user['avatarurl'] = $vb->options['bburl'] . '/image.php?' $vb->session->vars['sessionurl'] . 'u=' $user['userid'] . "&dateline=$avatar[dateline]";
        }

        
$default $user['avatarurl'];

        
$user['avatarurl'] = "<a class='vbridge_avatar_link' href='" $vb->options['bburl'] . "/member.php?u={$user['userid']}'><img alt='{$safe_alt}' src='{$user[avatarurl]}' class='avatar avatar-{$size} photo avatar-default' width='{$size}' height='{$size}' border='0'/></a>";
    }


    
/*    return apply_filters('get_avatar', $user['geturl'], $u, $size, $default, $user['username']);   */
    
return ($user['avatarurl']);


I found out later that this caused an error in the word press backend when editing comments. I restored the get_avatar function to the old code to fix this, and renamed by new function. Two questions.

1. It sounds like I should be able to use the same function for both if I can figure out how to create a user object. Can you give me a little tutorial on how to do that?

2. How is the get_avatar function called in the WP commenting backend? I don't really see it in the code and avatars are not being associated with the comments in the backend.

3. I lied, one more.... I would also like to display the avatar of each user who comments on a post as in this page:

http://www.michigan-sportsman.com/ms...an-youth-hunt/

But I don't know what to pass from this template function to make that happen. You can see my attempts at trying to get a comment author which have failed.

PHP Code:

class thesis_comment_meta extends thesis_comment {
    function 
build($comment) {
        global 
$thesis_design;
        
$this->meta $thesis_design->comments['comments']['options']['meta'];

        if (
is_array($this->meta)) {
            foreach (
$this->meta as $element_name => $element)
                if (
$element['show']) $output .= call_user_func(array($this$element_name), $comment) . "\n";
        }

        
thesis_hook_before_comment_meta();
        if (
$output) echo $output;
        
thesis_hook_after_comment_meta();
    }

    function 
author($comment) {
        return 
"<span class=\"comment_author\">" get_comment_author_link() . "</span>";
    }

    function 
avatar($comment) {
        global 
$vb;
        global 
$firephp;
        
    

        
$username $comment['comment_author'];
        
        
$firephp->log($comment,'Comment');
        
        
        if (
is_object($vb)) 
        { 
            
$vb_user_record $vb->db->query_first("SELECT * from " TABLE_PREFIX "user where username = '" $vb->db->escape_string($username) . "'");        
        }
        
$vb_userid $vb_user_record["userid"];
        

        
$avatar get_post_avatar($vb_user_record);
        
        
//        $avatar = get_avatar(get_comment_author_email(), $this->meta['avatar']['options']['size'], '');
        
$author_url get_comment_author_url();
        
$avatar_output = (empty($author_url) || $author_url == 'http://') ? $avatar "<a href=\"$author_url\" rel=\"nofollow\">$avatar</a>";
        return 
'<span class="avatar">' apply_filters('thesis_avatar'$avatar_output) . '</span>'#filter
    
}

    function 
date($comment) {
        
$timestamp = ($this->meta['date']['options']['time']) ? sprintf(__('%1$s at %2$s'), get_comment_date(stripslashes($this->meta['date']['options']['date_format'])), get_comment_time()) : get_comment_date(stripslashes($this->meta['date']['options']['date_format']));
        
$text = ($this->meta['number']['show']) ? $timestamp '<a href="#comment-' get_comment_ID() . '" title="Permalink to this comment" rel="nofollow">' $timestamp '</a>';
        return 
'<span class="comment_time">' apply_filters('thesis_comment_date'$text) . '</span>'#filter
    
}

    function 
number($comment) {
        if (!
$GLOBALS['comment_vars']) return; else $c $GLOBALS['comment_vars'];
        
$number = ($c['current'] - 1) * $c['per_page'] + did_action('thesis_hook_before_comment_meta') + 1;
        return 
'<span class="comment_num"><a href="#comment-' get_comment_ID() . "\" title=\"Permalink to this comment\" rel=\"nofollow\">$number</a></span>";
    }

    function 
edit($comment) {
        if (
get_edit_comment_link()) return '<span class="edit_comment">' apply_filters('thesis_edit_comment_link''<a href="' get_edit_comment_link() . '" rel="nofollow">' __('edit''thesis') . '</a>') . '</span>'#filter
    
}




All times are GMT -4. The time now is 07:01 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2024, vBulletin Solutions, Inc.