Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show specific avatar


  • LPH2005
    Participant

    @lph2005

    I’m working on a integrating mediawiki better with buddypress. Right now, I’d love to get my avatar and another teacher’s avatar showing in the upper corner of the mediawiki. These would be linked to the proper course material. Right now I just have text, but the avatars would be better.

    This is for getting the logged in user’s avatar:
    bp_loggedin_user_avatar( ‘type=thumb&width=30&height=30’ )

    What is used to get a specific user’s avatar? Say, I want the admin avatar?

    As always – thank you!

    Oh – if you are interested – I have http://www.thechembook.com mediawiki set so that the header from buddypress is now controlling the major part of the navigation. The same is true for the footer. It was far easier to do than I thought. Anyway – hopefully someone has an answer to my question :)

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

  • Brandon Allen
    Participant

    @cnorris23

    Have a look at bp_core_fetch_avatar(). It accepts a number of arguments you’ll want to explore for your use case. The most important being $item_id, which in your case would be your user id number and that user id of your teacher.


    LPH2005
    Participant

    @lph2005

    Thank you. Since I’m not good with php, my interpretation doesn’t seem to work. This is the echo statement to get the avatar to show, however, I’m not sure that the user_id argument works. The area for this statement is blank.

    echo bp_core_fetch_avatar(‘type=thumb&width=30&height=30&user_id=1’);


    Brandon Allen
    Participant

    @cnorris23

    The user_id argument doesn’t exist because there is no user_id argument. The argument that accepts a user id is the item_id argument as I stated above. Try this:

    echo bp_core_fetch_avatar( array( ‘width’ => 30, ‘height’ => 30, ‘item_id’ => 1 ) );

    If all you need is the thumbnail, then you don’t need the ‘type’ argument, as it defaults to thumbnail.


    LPH2005
    Participant

    @lph2005

    Thank you for hanging in there and giving a clear explanation. I didn’t understand what you meant on the first reply. Unfortunately, setting either item_id to the user_id works (mine or the other teachers). So, I’ll keep fussing and try to figure out what is wrong. I tried a copy-paste first – maybe a tic is wrong – or something more obvious that I’m doing wrong.

    Update
    Yes, I got it to work. It was the copy paste issue of the ‘ …

    Thank you for showing me how to do this piece of code correctly!


    Brandon Allen
    Participant

    @cnorris23

    I just tested this, and the code works. You may need to make sure apostrophes around each array item (width,height,item_id) are in fact standard apostrophes not single quotation marks, or single curly quotes as some call them. BP seems to transform apostrophes to single curly quates which would cause the code to fail.


    LPH2005
    Participant

    @lph2005

    You are correct. It was the apostrophe issue. Fantastic. Thank you.


    Brandon Allen
    Participant

    @cnorris23

    No worries. Glad you got it fixed.


    jolaedana
    Member

    @jolaedana

    THANK you for this answer, it suit my purposes exactly!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Show specific avatar’ is closed to new replies.
Skip to toolbar