Skip to:
Content
Pages
Categories
Search
Top
Bottom

Wrong avatar being displayed

  • Avatar of viniciusandre
    Vinicius Massuchetto
    Participant

    @viniciusandre

    Hi everyone!

    I coded two widgets, one to list the most active blogs on the website home, and another to show up a profile on blogs.

    The weird thing is that using the same method for both widgets, they display different avatars. In my blog home I got the right avatar, but on blog profiles sidebar widget I get a gravatar “smiling square” generated one, not the one uploaded via Buddypress.

    The method (exactly the same in both widgets) is something like:
    —-
    global $blog_id;
    $user = get_blog_owner ($blog_id) // function to not get site admin users
    echo get avatar ($user->ID, 96); // bp_core_fetch_avatar(‘item_id=’.$user->ID) does not work, either
    —-

    Hope someone can help me on this.
    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Avatar of viniciusandre
    Vinicius Massuchetto
    Participant

    @viniciusandre

    I don’t know if there’s something wrong with it, but that’s the get_blog_owner, just in case.


    function get_blog_owner($blog_id = “”, $one_result = true) {
    if (!$blog_id) global $blog_id;
    if (!is_numeric($blog_id)) return “Blog ID must be an integer.”;

    global $wpdb;

    //first we’ll attempt to find the author by matching the admin email against users
    $qryAuthor = $wpdb->get_var(“SELECT ID FROM “.$wpdb->users.”, “.$wpdb->base_prefix.$blog_id.”_options WHERE option_name = ‘admin_email’ AND option_value = user_email;”);
    if ($qryAuthor) return get_userdata($qryAuthor);

    //if that fails, we’ll look for the blog administrator, user level 10
    $qryAuthor = $wpdb->get_results(“SELECT user_id FROM “.$wpdb->usermeta.” WHERE meta_key = ‘”.$wpdb->base_prefix.$blog_id.”_user_level’ AND meta_value = 10;”);
    if ($wpdb->num_rows <= 0) return false; //if there are still no results, return false
    if ($wpdb->num_rows == 1 || $one_result == true) return get_userdata($qryAuthor[0]->user_id); //if there’s only one blog admin or only want one result, we’ll return that

    //otherwise return an array of administrators
    $authors = array();
    foreach ($qryAuthor as $author) $authors[] = get_userdata($author->user_id);
    return $authors;
    }


Viewing 1 replies (of 1 total)

The topic ‘Wrong avatar being displayed’ is closed to new replies.