Skip to:
Content
Pages
Categories
Search
Top
Bottom

Help with “use a filter with the ID of the blog” etc.


  • Mandy
    Participant

    @mandy51

    Hi. I’ve been trying for months, off and on, to get my blog listing to show the avatar of the associated group instead of my avatar (as the default). I finally dug into the code of the plugin to see what was going on and I see there is this comment in the function called “bp_blog_avatar()”. This explains why my avatar is showing up for every blog, but I still don’t understand what I need to do to change it.

    I’m guessing the “future BuddyPress versions” have not yet materialized. So what’s this business about applying a filter? Any pointers most appreciated. I do have some basic PHP knowledge, just a little rusty.

    I’m running BP 1.2.7 and WPMU 3.0.4

    Thanks.

    /***
    210 * In future BuddyPress versions you will be able to set the avatar for a blog.
    211 * Right now you can use a filter with the ID of the blog to change it if you wish.
    212 * By default it will return the avatar for the primary blog admin.
    213 */

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

  • Boone Gorges
    Keymaster

    @boonebgorges

    You will have te create a custom function, either in your theme’s functions.php or in plugins/bp-custom.php, that filters the output of that function and replaces it with the avatar of your choice. Eg, if your blog_id is 5,
    ‘function my_blog_avatar( $old_avatar ) {
    // Do some stuff to get the avatar you want, then
    return $new_avatar;
    }
    add_filter( ‘bp_get_blog_avatar_5’, ‘my_blog_avatar’ );`

    The ‘do some stuff’ part will depend highly on your setup. If by ‘the associated group’ you mean that you are using bp-groupblog, then you will likely have to do some direct queries of the groupmeta database table to find the group that is associated with a particular blog (I don’t think that the plugin stores that info in a place that is easily accessible by blog_id). Then you will use some permutation of bp_core_fetch_avatar() to pull up the avatar for that group_id.

    Good luck!


    Mandy
    Participant

    @mandy51

    Thanks for the advice. Can you comment on this thread: http://premium.wpmudev.org/forums/topic/blog-avatars
    It’s old and I want to make sure it is still the case.

    Thanks


    Boone Gorges
    Keymaster

    @boonebgorges

    That thread is correct that there are no blog avatares built into BP. But it is incorrect about being able to display custom avatars in blog directories. The strategy I outline above will do just that.


    Mandy
    Participant

    @mandy51

    Alternately, can you tell me how you got the blog listing on your CUNY site to show, at the very least, the avatar of the most recent poster instead of the admin avatar?

    Thanks


    Cam
    Participant

    @crazycoolcam

    @boonebgorges

    I am a complete newbie when it comes to this. I tried to utilize the funciton you created above and it results in an error: Unexpected return.

    I imagine I am missing something obvious but here is my code:
    `function my_blog_avatar_1( $old_avatar ) {
    bp_core_fetch_avatar( array( ‘item_id’ => ‘1’, ‘type’ => $type, ‘alt’ => $alt, ‘width’ => $width, ‘height’ => $height, ‘class’ => $class ) ) // Do some stuff to get the avatar you want, then
    return $new_avatar;
    }
    add_filter( ‘bp_get_blog_avatar_1?, ‘my_blog_avatar_1’ );`

    Thanks in advance for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Help with “use a filter with the ID of the blog” etc.’ is closed to new replies.
Skip to toolbar