Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 126 through 150 (of 246 total)
  • Author
    Search Results
  • #140349
    meg@info
    Participant

    Hi,
    Check this :)


    /**
    * Check if the current user has an uploaded avatar
    * @return boolean
    */
    function current_user_has_avatar() {
    global $bp;
    if ( bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'no_grav' => true,'html'=> false ) ) != bp_core_avatar_default() )
    return true;
    return false;
    }
    #138846
    odiggy
    Participant

    Thanks Roger!

    #138837
    Paul Wong-Gibbs
    Keymaster

    Confirmed. Thanks for investigating.

    #138835
    Paul Wong-Gibbs
    Keymaster

    Ah hah. Hopefully we can get someone to test reversing that change on the Salutation theme; we may be on to a winner. Thanks Roger

    #138833
    Roger Coathup
    Participant

    I suspect that it is this ‘fix’ that has broken the functionality: https://buddypress.trac.wordpress.org/ticket/4215

    #138476
    Geordee
    Participant

    I had to make this fix after the update
    In bp-core-avatars.php I commented out
    `return apply_filters( ‘bp_core_fetch_avatar’, ‘<img src="' . `
    onward and added
    `return apply_filters( ‘bp_core_fetch_avatar_url’, $gravatar );`

    Also commented
    `return apply_filters( ‘bp_core_fetch_avatar’, ‘<img src="' .`
    and added
    `return apply_filters( ‘bp_core_fetch_avatar_url’, $avatar_url );`

    Not sure whether this is correct or not, but my site works.

    I do not see any other issue.

    #136310
    modemlooper
    Moderator

    bp_displayed_user_avatar only works on a members profile page use bp_core_fetch_avatar

    not all functions work out of their components

    #134179
    meg@info
    Participant

    Thanks @shanebp for answer,

    I wanted a clean solution (just function from buddyrpess) but :(– .
    Any way, here is my function, i used bp_core_avatar_default() to return the default avatar.


    /**
    * Check if the current user has an uploaded avatar
    * @return boolean
    */
    function current_user_has_avatar() {
    global $bp;
    if ( bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'no_grav' => true,'html'=> false ) ) != bp_core_avatar_default() )
    return true;
    return false;
    }

    Hope this help some one.
    Closed.

    #134167
    shanebp
    Moderator

    So it will always be true due to the default avatar.

    There might be an existing BP method to ignore both grav and default, but I don’t know what it is.

    So you could string-check, something like this:

    `
    function user_has_avatar() {
    global $bp;

    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => $bp->loggedin_user->id, ‘no_grav’ => true, ‘html’=>false) );

    $pos = strpos($avatar, ‘mystery-man’);
    if ($pos === false) return true;

    return false;
    }
    `

    #134166
    meg@info
    Participant

    Here is my code

    http://pastebin.com/dCWN34qx

    This my code in functions.php


    function user_has_avatar() {
    global $bp;
    if ( !bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'no_grav' => true ) ) )
    return false;
    return true;
    }

    I try to check this in header.php,



    // test one with bp_get_user_has_avatar function
    global $bp;
    if( !bp_get_user_has_avatar()) :
    // echo html message warning
    endif;

    // test two with user_has_avatar function
    if( !user_has_avatar() ) :
    // echo html message warning
    endif;

    bp_core_fetch_avatar( array( ‘item_id’ => $bp->loggedin_user->id, ‘no_grav’ => true, ‘html’=>false )
    return this string :

    http://localhost/wordpress-buddypulse/wp-content/plugins/buddypress/bp-core/images/mystery-man.jpg

    and not false like describe in buddypress docs ( when no_grav is true function will return false if no avatar is added)

    bp_get_user_has_avatar() is used in memberssingleprofilechange-avtar.php , mybe i need to call a funtion to load the data of current member or somthing like that…

    Thanks advance @shanebp for help :)

    #133945

    In reply to: link to avatar by id

    shanebp
    Moderator

    Why would you want to link to an avatar?

    If you mean show their avatar as a link to their profile…
    Then if you know what that person’s user_id is… say as $that_member_id

    `
    $avatar=bp_core_fetch_avatar(array(“item_id”=>$that_member_id,”type”=>”thumb”,”height”=>32,”width”=>32));
    $avatar_link = “” . $avatar . ““;
    echo $avatar_link;
    `

    #133865
    adambundy
    Member

    I found a solution for this. Hope it helps someone. Note that I am fetching the value of $user_id earlier in my loop.

    `if ( function_exists(‘bp_core_fetch_avatar’) ) {
    echo apply_filters( ‘bp_post_author_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $user_id, ‘type’ => ‘full’, ‘width’ => 120, ‘height’ => 120 ) ) );
    } else if ( function_exists(‘get_avatar’) ) {
    get_avatar( $user_id, $size = ‘120’);
    }`

    #133763
    craftcore
    Participant

    Thanks for the tip, Paul! I have nice crisp avatars now; not a blurry pixel in sight!

    Strangely, calling get_avatar() still resulted in blurry pics. When I used the bp_core_fetch_avatar function, it worked perfectly.

    (See image of the results side by side: https://twitter.com/#!/pangepange/status/197016926789181441/photo/1/large )

    The function didn’t work as is, but when I changed item_id to “$comment->user_id”, the avatars worked on my theme.

    `<?php if ( function_exists( 'bp_core_fetch_avatar' ) ) :
    echo bp_core_fetch_avatar( array(
    ‘item_id’ => $comment->user_id,
    ‘type’ => ‘full’,
    ‘width’ => 75,
    ‘height’ => 75
    ));
    endif;
    ?>`

    Thanks so much for the help!

    #133729
    Paul Wong-Gibbs
    Keymaster

    WordPress’ get_avatar() should work fine. For post/page comments, I would actually suggest using get_avatar() instead of bp_core_fetch_avatar() so that your site doesn’t break if you decide to turn off or stop using BuddyPress.

    #133725
    r-a-y
    Keymaster

    Hi,

    In your comments template, you should try using the BP avatar function:
    `
    if ( function_exists( ‘bp_core_fetch_avatar’ ) ) :
    echo bp_core_fetch_avatar( array(
    ‘item_id’ => THE_USER_ID,
    ‘type’ => ‘full’,
    ‘width’ => 75,
    ‘height’ => 75
    ));
    endif;
    `

    #132635

    In reply to: Full BP Avatar URL

    shanebp
    Moderator

    Try this:
    `
    global $post; // probably don’t need this
    $author_id=$post->post_author;

    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => $author_id, ‘type’ => ‘full’ ) );
    echo $avatar;
    `

    If you want to specify the height / width you can do this:
    `
    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => $author_id, ‘type’ => ‘full’, ‘height’=>105,’width’=>105 ) );
    `

    #129437
    daveC87
    Member

    The custom Functions I added area as follows: (When I delete the bp-custom.php everything works fine again)

    // Setups up Type=Full avatar pics for BP-post author
    function bp_custompost_author_avatar() {
    global $post;

    if ( function_exists(‘bp_core_fetch_avatar’) ) {
    echo apply_filters( ‘bp_post_author_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $post->post_author, ‘type’ => ‘full’, ‘width’ => ’70’, ‘height’ => ’70’ ) ) );
    } else if ( function_exists(‘get_avatar’) ) {
    get_avatar();
    }
    }

    // Changes order for member profile menu items
    function bbg_change_profile_tab_order() {
    global $bp;

    $bp->bp_nav = 20;
    $bp->bp_nav = 30;
    $bp->bp_nav = 40;
    $bp->bp_nav = 50;
    $bp->bp_nav = 60;
    $bp->bp_nav = 70;
    $bp->bp_nav = 80;

    $bp->bp_nav = false;
    $bp->bp_nav = false;

    }
    add_action( ‘bp_setup_nav’, ‘bbg_change_profile_tab_order’, 999 );*/

    // Setup the navigation
    // Props to http://wordpress.stackexchange.com/questions/16223/add-buddypress-profile-menu-item for helping me figure this out
    // and http://themekraft.com/customize-profile-and-group-menus-in-buddypress/
    function my_setup_nav() {
    global $bp;

    bp_core_new_nav_item( array(
    ‘name’ => __( ‘my adventure list’, ‘buddypress’ ),
    ‘slug’ => ‘my-adventure-list’,
    ‘position’ => 10,
    ‘screen_function’ => ‘my_adventure_list_link’,
    ‘show_for_displayed_user’ => true,
    ‘default_subnav_slug’ => ‘my-adventure-list’,
    ‘item_css_id’ => ‘my-adventure-list’
    ) );
    }

    add_action( ‘bp_setup_nav’, ‘my_setup_nav’, 1000 );

    function my_adventure_list_title() {
    echo ‘My Adventure List’;
    }

    function my_adventure_list_content() {
    ?>


    <?php
    }

    function my_adventure_list_link () {
    add_action( ‘bp_template_title’, ‘my_adventure_list_title’ );
    add_action( ‘bp_template_content’, ‘my_adventure_list_content’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/my-adventure-list’ ) );
    }

    ?>

    #129389
    dgodot
    Member

    Thanks, mercime, but I’m not sure I understand. I’m not trying to change the size of avatars in the comments section, but rather in the sidebar for a multi-user buddypress site.

    I see that in your code you’re using bp_core_fetch_avatar(). That function seems to produce the same output as get_avatar() for me — which is the avatar thumbnail scaled to whatever size I specify. Am I missing something?

    #129238
    r-a-y
    Keymaster

    That’s old, old code.

    Use something like this to change the default group avatar:

    `
    // turn gravatars off
    add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ );

    // change the default group avatar
    function ray_change_group_avatar_default() {
    return ‘URL TO GROUP DEFAULT AVATAR’;
    }
    add_filter( ‘bp_core_default_avatar_group’, ‘ray_change_group_avatar_default’ );`

    Untested! This only works with gravatars turned off.

    #127926

    In reply to: Conditional Avatars

    r-a-y
    Keymaster

    Since you’re using:
    `add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ );`

    You can also define your mystery man image with:
    http://pastebin.com/AST92STz

    For LINKTOYOURIMAGE.gif, try making it a transparent GIF. That’s probably the best you can do at the moment.

    Also, a ticket was just brought up to add CSS classes to avatars:
    https://buddypress.trac.wordpress.org/ticket/3922

    Keep an eye on that one.

    #127885

    In reply to: Conditional Avatars

    InHouse
    Member

    Is there a filter I can add to bp-customs.php that will skip the mystery man?
    `add_filter( ‘bp_core_default_avatar_no_grav’, ‘__return_true’ );`

    I’m already using the one that skips the Gravatar.
    `add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ );`

    Any ideas? My last resort would be to hack bp-core-avatars.php but I don’t want to do anything preventing upgrading of course.

    #127778
    drummergirl
    Participant

    Found what I needed…

    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => ‘4’, ‘object’ => ‘group’, ‘type’ => ‘full’, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, ‘css_id’ => $id, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height ) );

    Never mind, got it. Had to write a custom function:

    `function bp_custompost_author_avatar() {
    global $post;

    if ( function_exists(‘bp_core_fetch_avatar’) ) {
    echo apply_filters( ‘bp_post_author_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $post->post_author, ‘type’ => ‘full’ ) ) );
    } else if ( function_exists(‘get_avatar’) ) {
    get_avatar();
    }
    }
    `

    modemlooper
    Moderator

    If it’s a members page use bp_core_fetch_avatar()

    #125126

    In reply to: User Avatar Hook

    Paul Wong-Gibbs
    Keymaster

    Take a look at BP’s bp_core_fetch_avatar_filter() function.

Viewing 25 results - 126 through 150 (of 246 total)
Skip to toolbar