WordPress.org

Ready to get started?Download WordPress

Forums

WP phpBB Bridge
Author Avatar (7 posts)

  1. mbazdell
    Member
    Posted 2 years ago #

    Okay so I've been looking into the functions.php in regards to getting author avatars used as well instead of it just being for commenter's. Has anybody done this before? I almost think I need to write a new function to accomplish this but would rather not.

    http://wordpress.org/extend/plugins/wp-phpbb-bridge/

  2. mbazdell
    Member
    Posted 2 years ago #

    <?php echo get_avatar( get_the_author_meta( 'user_email' ), '50' ); ?>

    Okay so that's what is displaying the image.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    That's the function that is grabbing the commenter's avatar. I have a feeling the issue is with

    $qr = "SELECT u.user_avatar, u.user_avatar_typeFROM" . $table_prefix . "usersu WHERE u.user_email= '" . $comment->comment_author_email . "'";

    specifically

    $comment->comment_author_email . "'";`

    I can't find where $comment is getting filled. It's working for comments no problem, but what I see, $comment is only getting passed "50". Any pointers?

  3. mbazdell
    Member
    Posted 2 years ago #

    Alright.. I got it working. I had to create a new function and then edit the theme a bunch. got it working!

  4. Mark
    Member
    Posted 2 years ago #

    Any chance you can post the solution? Cheers

  5. mbazdell
    Member
    Posted 2 years ago #

    No! It's a secret!

    Okay so I'm not a php programmer but I know enough to figure things out. I couldn't figure out a way to make it work within the same function because they have to call different variables from the SQL database. So what I did was copy the function, and then just change the variable..

    function get_forum_author_avatar($authemail, $size)
    {
        global $user;
    
        $phpbb_config = trim(get_option('wpb_path'));
    
            $phpbb_config = trim(get_option('wpb_path'));
            require($phpbb_config);
    
            $cn = mysql_pconnect($dbhost . ":" . $dbport, $dbuser, $dbpasswd);
    
            if($cn)
            {
                if(@mysql_select_db($dbname))
                {
                    $qr = "SELECT u.<code>user_avatar</code>, u.<code>user_avatar_type</code> FROM <code>&quot; . $table_prefix  . &quot;users</code> u WHERE u.<code>user_email</code> = '" . $authemail . "'";
                    $rs = @mysql_query($qr, $cn);
                }
    
                while($i = mysql_fetch_assoc($rs))
                {
                    $avatar = "<img class=\"avatar photo\" src=\"" . wpb_get_avatar($i['user_avatar'], $i['user_avatar_type']) . "\" alt=\"\" />";
                }
            }
    
        return $avatar;
    }

    I put this right after the get_forum_avatar function. Then to make it work, I manually edited the theme file wherever it called for get_avatar for the author avatar, I changed it to get_forum_author_avatar. That was it!

  6. undead1
    Member
    Posted 2 years ago #

    for me not work, need help :(

  7. undead1
    Member
    Posted 2 years ago #

    i don't find get_avatar work with get_forum_author_avatar, can u help me mbazdell,

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic