Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] bp_core_fetch_avatar only appear on buddypress pages


  • mathieu.urstein
    Participant

    @mojomateo

    I’m using the
    bp_core_fetch_avatar( array( 'html' => false ) );
    code.

    But it only works when i’m on buddypress generated page.

    How can I make it work everywhere on my website?

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

  • modemlooper
    Moderator

    @modemlooper

    $id = //pass the id of a user
    bp_core_fetch_avatar( array( ‘item_id’ => $id, ‘html’ => false ) );

    If you are not on a user page then you must tell it what id of the avatar to get.

    bp_displayed_user_id
    bp_loggedin_user_id


    mathieu.urstein
    Participant

    @mojomateo

    thank you @modemlooper

    I did :

    $userid = bp_loggedin_user_id();
    $avatarurl = bp_core_fetch_avatar( array( ‘item_id’ => $userid, ‘html’ => false ) );

    But the problem is still the same,
    what did I do wrong?

    Thanks.


    modemlooper
    Moderator

    @modemlooper

    <?php
    $userid = bp_loggedin_user_id();
    $avatarurl = bp_core_fetch_avatar( array( ‘item_id’ => $userid, ‘html’ => false ) );
    echo $avatarurl;
    ?>

    rewrite the quote marks, if you cut and paste it can have funky formatting. If you want to display the avatar instead of getting link:

    <?php
    $userid = bp_loggedin_user_id();
    echo bp_core_fetch_avatar( array( ‘item_id’ => $userid) );
    ?>

    mathieu.urstein
    Participant

    @mojomateo

    @modemlooper

    thank you the problem was the quotes 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] bp_core_fetch_avatar only appear on buddypress pages’ is closed to new replies.
Skip to toolbar