Skip to:
Content
Pages
Categories
Search
Top
Bottom

User avatar in side widget


  • andrew55
    Participant

    @andrew55

    I’ve been searching for a plugin and can’t seem to find anything. I’m simply trying to display the current logged-in user’s avatar, with a link to their BP profile, in a side-bar widget. If user has no avatar, then the default avatar shows.

    My idea was to display this widget in bbpress.

    WP PHP widget plugin can easily be used to post the php (I just can’t figure out what the php should be).

    The closest thing I could find is…


    <?php
    wp_get_current_user();
    $size = array(60,60); // this is the size of the avatar
    echo get_avatar( $current_user->user_email, $size, $default, $current_user->display_name );
    ?>

    ..but I couldn’t get this to work. Any suggestions greatly appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)

  • shanebp
    Moderator

    @shanebp

    <?php $user_id = get_current_user_id(); ?>
    <a href="<?php echo bp_core_get_user_domain( $user_id ); ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id ) ); ?></a>

    andrew55
    Participant

    @andrew55

    Thanks – works great.

    Quick question – where would I put a div class such as “custom-avatar” in the code so I can adjust size of avatar?

    I tried wrapping the whole snippet in a div with no success.


    andrew55
    Participant

    @andrew55

    IN the sidebar widget, avatar is displaying as 50px wide/tall. Any method of getting it display at 200px?

    Thanks for any help.


    shanebp
    Moderator

    @shanebp

    bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full' ) );

    ‘full’ will be the large size at whatever that is set to – usually 150px.


    andrew55
    Participant

    @andrew55

    Perfect! Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘User avatar in side widget’ is closed to new replies.
Skip to toolbar