Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_fetch_avatar'

Viewing 25 results - 176 through 200 (of 310 total)
  • Author
    Search Results
  • #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 :)

    meg@info
    Participant

    Hi ,

    I want to check if the current member have an avatar or not in a front page, i try this too method
    1. bp_get_user_has_avatar function return always false

    2 . if ( !bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘no_grav’ => true ) ) ) return always false too.

    Any help thank you ?

    #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 ) );
    `

    #28084
    bigt11
    Participant

    **UPDATED**
    -when multiple results show, it will show the AKA @ name properly now
    -added the same limit on the results returned that the original code used

    Like a lot of people, I want the auto suggest to look for display names and nice names. Below is my code to do just that. Im using a $wpdb->get_results to do my search. Im also changing up the displayed text to also include that users nice name so if the user is searching for “bob”. A user’s display name might be “bob9”, but there login = “I_am_bob” It will display avatar then display name then @username

    example output
    [avatar] bob9 AKA -> @i_am_bob

    Warning im not a coding master, but it seems to work for me. Below is the whole class-bplabs-autosuggest.php so just make a backup of your site, and overwrite inside class-bplabs-autosuggest.php with the code below

    <?php
    /**
    * @package BP_Labs
    * @subpackage Mentions_Autosuggest
    */
    
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) )
    exit;
    
    /**
    * Implements the <a href='http://buddypress.org/community/members/message/' rel='nofollow'>@message</a> autosuggest experiment.
    *
    * <a href='http://buddypress.org/community/members/since/' rel='nofollow'>@since</a> 1.0
    */
    class BPLabs_Autosuggest extends BPLabs_Beaker {
    /**
    * Enqueue javascript
    *
    * <a href='http://buddypress.org/community/members/since/' rel='nofollow'>@since</a> 1.0
    */
    public function enqueue_script() {
    $dir = WP_PLUGIN_URL . '/bp-labs/beakers/js/jquery.mentions';
    
    if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    wp_enqueue_script( 'bplabs-autosuggest-js', "{$dir}.dev.js", array( 'jquery' ), '1.2' );
    else
    wp_enqueue_script( 'bplabs-autosuggest-js', "{$dir}.js", array( 'jquery' ), '1.2' );
    
    wp_localize_script( 'bplabs-autosuggest-js', 'BPMentions', array(
    'error1'     => __( 'Sorry, an error occurred.', 'bpl' ),
    'error2'     => _x( 'Please try again.', 'an error occurred', 'bpl' ),
    'searching'  => _x( 'Searching for members to mention... one moment please...', 'started a search', 'bpl' )
    ) );
    
    // This bit of javascript is what you could add directly to your theme
    $dir = WP_PLUGIN_URL . '/bp-labs/beakers/js/autosuggest';
    
    if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    wp_enqueue_script( 'bplabs-autosuggest-theme-js', "{$dir}.dev.js", array( 'bplabs-autosuggest-js' ), '1.0' );
    else
    wp_enqueue_script( 'bplabs-autosuggest-theme-js', "{$dir}.js", array( 'bplabs-autosuggest-js' ), '1.0' );
    }
    
    /**
    * Enqueue CSS
    *
    * <a href='http://buddypress.org/community/members/since/' rel='nofollow'>@since</a> 1.0
    */
    public function enqueue_style() {
    $dir = WP_PLUGIN_URL . '/bp-labs/beakers/css/jquery.mentions';
    
    if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    wp_enqueue_style( 'bplabs-autosuggest', "{$dir}.dev.css", array(), '1.0' );
    else
    wp_enqueue_style( 'bplabs-autosuggest', "{$dir}.css", array(), '1.0' );
    }
    
    /**
    * Add the AJAX callback for the mention_autosuggest() method.
    *
    * <a href='http://buddypress.org/community/members/since/' rel='nofollow'>@since</a> 1.0
    */
    protected function register_actions() {
    add_action( 'wp_ajax_activity_mention_autosuggest', array( 'BPLabs_Autosuggest', 'mention_autosuggest' ) );
    }
    
    /**
    * AJAX receiver for the @mention autosuggest jQuery library. Performs a search on the string provided and returns matches.
    *
    * <a href='http://buddypress.org/community/members/global/' rel='nofollow'>@global</a> object $bp BuddyPress global settings
    * @return mixed Either HTML or JSON. If error, "-1" for missing parameters, "0" for no matches.
    * <a href='http://buddypress.org/community/members/see/' rel='nofollow'>@see</a> bp-labs/beakers/js/jquery.mentions.dev.js
    * <a href='http://buddypress.org/community/members/since/' rel='nofollow'>@since</a> 1.0
    */
    public function mention_autosuggest() {
    global $bp;
    
    if ( empty( $_POST ) || empty( $_POST ) )
    exit( '-1' );
    
    // Sanitise input
    $search_query = implode( '', (array) preg_replace( array( '|^https?<img src="smileys/irritated.gif" width="" height="" alt=":/" title=":/" class="bbcode_smiley" />/|i', '|*|', '|@|' ), '', $_POST ) );
    if ( empty( $search_query ) )
    exit( '-1' );
    
    //$args = array(
    //	'count_total' => false,
    //	'number'      => (int) $_POST,
    //	'search'      => "{$search_query}*"
    //);
    
    if ( !empty( $bp->loggedin_user->id ) )
    $args = array( $bp->loggedin_user->id );
    
    if ( bp_is_username_compatibility_mode() ) {
    //$args  = array( 'ID', 'user_login' );
    //$args = 'login';
    
    }
    else {
    //$args  = array( 'ID', 'display_name' );
    //$args = 'nicename';
    }
    
    $args = apply_filters( 'bpl_mention_autosuggest_args', $args );
    
    // Search users
    //TAO custom search using display name
    global $wpdb;
    $TAO_limit_results = (int) $_POST;
    $user_search_results = $wpdb->get_results( "SELECT ID, user_nicename, display_name, user_login FROM wp_users WHERE user_login like'%$search_query%' OR display_name like '%$search_query%' LIMIT 0, $TAO_limit_results" );
    //print_r($user_search_results);
    echo "<br>";
    echo 'Searching for members to mention with "' .$search_query .'" in their name.';
    echo "<br>";
    echo 'Click on the user you wish to mention.';
    $args = array(
    'search'      => "*{$search_query}*"
    
    );
    //$user_search_results = new WP_User_Query( $args );
    //print_r($user_search_results);
    if ( empty( $user_search_results ) ) {
    
    // Return JSON
    if ( !empty( $_POST ) && 'json' == $_POST ) {
    exit( json_encode( false ) );
    
    // Return HTML
    } else {
    printf( '<li class="section error"><span>%s</span> %s
    </li>', _x( 'No matches found.', 'no search results', 'bpl' ), _x( 'Please check your spelling.', 'no search results', 'bpl' ) );
    exit();
    }
    }
    
    // If logged in, get user's friends
    $friend_ids = array();
    if ( !empty( $bp->loggedin_user->id ) && bp_is_active( 'friends' ) )
    $friend_ids = friends_get_friend_user_ids( $bp->loggedin_user->id );
    
    $search_results = array( 'friends' => array(), 'others' => array() );
    
    // Build results
    foreach ( (array) $user_search_results as $user ) {
    $result         = new stdClass;
    $result->avatar = bp_core_fetch_avatar( array( 'item_id' => $user->ID, 'width' => 30, 'height' => 30, 'type' => 'thumb', 'alt' => __( 'Profile picture of %s', 'bpl' ) ) );
    $result->name   = bp_core_get_user_displayname( $user->ID );
    //TAO adding the nicename to do a AKA
    $result->TAO_user_nicename = $user->user_nicename;
    
    if ( bp_is_username_compatibility_mode() )
    $result->id = $user->user_login;
    else
    $result->id = $user->user_nicename;
    
    if ( in_array( $user->ID, (array) $friend_ids ) )
    $search_results[] = $result;
    else
    $search_results[]  = $result;
    }
    
    apply_filters_ref_array( 'bpl_mention_autosuggest', array( &$search_results, $args ) );
    
    // Return JSON
    if ( !empty( $_POST ) && 'json' == $_POST ) {
    exit( json_encode( $search_results ) );
    
    // Return HTML
    } else {
    $html = array();
    
    foreach ( $search_results as $section => $items ) {
    if ( empty( $items ) )
    continue;
    
    // Friends and other users
    if ( 'friends' == $section || 'others' == $section ) {
    if ( 'friends' == $section ) {
    $html[] = sprintf( '<li class="section friends">%s
    </li>', __( 'Your friends', 'bpl' ) );
    
    } elseif ( 'others' == $section ) {
    if ( !empty( $search_results ) )
    $html[] = sprintf( '<li class="section other">%s
    </li>', sprintf( __( 'Other people on %s', 'bpl' ), get_bloginfo( 'name', 'display' ) ) );
    else
    $html[] = sprintf( '<li class="section other">%s
    </li>', sprintf( __( 'People on %s', 'bpl' ), get_bloginfo( 'name', 'display' ) ) );
    }
    
    foreach ( $items as $item )
    $html[] = sprintf( '<li class="%s">%s
    </li>', esc_attr( $item->id ), $item->avatar . esc_html( $item->name ) . '&nbsp;&nbsp&nbsp;&nbsp;AKA&nbsp;&nbsp;---> @' .$item->TAO_user_nicename );
    
    // For third-party extensions
    } else {
    $custom_section = apply_filters( 'bpl_mention_autosuggest_custom_section', false, $section, $items );
    
    if ( !empty( $custom_section ) )
    $html = array_merge( $html, (array) $custom_section );
    }
    }
    
    // Safety net
    if ( empty( $html ) )
    $html[] = sprintf( '<li class="section error"><span>%s</span> %s
    </li>', _x( 'No matches found.', 'no search results', 'bpl' ), _x( 'Please check your spelling.', 'no search results', 'bpl' ) );
    
    exit( apply_filters( 'bpl_mention_autosuggest_html', implode( PHP_EOL, $html ), $html ) );
    }
    }
    }
    new BPLabs_Autosuggest();
    ?>
    drummergirl
    Participant

    I built a custom widget with an activity stream so my client can set a group ID to display a “featured group” in the sidebar. The group avatar displays as well as the activity stream. All of the activity links work correctly, except for comments and favorites.

    Comments goes to the home page and favorites returns a 404.

    Favorites: http://www.prolifeplanet.com/activity/favorite/114/?_wpnonce=6d82795544

    Here is my widget code:

    `
    add_action( ‘widgets_init’, ‘featured_bpgroup_widget’ );

    /**
    * Register our widget
    */
    function featured_bpgroup_widget() {
    register_widget( ‘tfd_Featured_BPGroup’ );
    }

    /**
    * Add widget style
    */

    add_action(‘wp_enqueue_scripts’, ‘bpfg_styles’);

    function bpfg_styles() {
    wp_enqueue_style(‘bpfg-style’, plugin_dir_url(__FILE__) . ‘bpfg-style.css’);
    }

    /*** Widget class ***/
    class tfd_Featured_BPGroup extends WP_Widget {

    /**
    * Widget setup.
    */
    function tfd_Featured_BPGroup() {
    /* Widget settings. */
    $widget_ops = array( ‘classname’ => ‘bp_fgroup’, ‘description’ => __(‘A widget to display a featured buddy press group.’, ‘fgroup’) );

    /* Widget control settings. */
    $control_ops = array( ‘width’ => 300, ‘height’ => 350, ‘id_base’ => ‘featured-bpgroup’ );

    /* Create the widget. */
    $this->WP_Widget( ‘featured-bpgroup’, __(‘Featured BP Group’, ‘fgroup’), $widget_ops, $control_ops );
    }

    /**
    * How to display the widget on the screen.
    */
    function widget( $args, $instance ) {
    extract( $args );

    /* Our variables from the widget settings. */
    $title = apply_filters(‘widget_title’, $instance );
    $description = $instance;
    if ( !$groupid = (int) $groupid )$groupid = 4;

    /* Before widget (defined by themes). */
    echo $before_widget;

    /* Display the widget title if one was input (before and after defined by themes). */
    if ( $title )
    echo $before_title . $title . $after_title;

    /* Display Group Avatar */
    $avatar = bp_core_fetch_avatar( array( ‘item_id’ => $groupid, ‘object’ => ‘group’, ‘type’ => ‘full’, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, /* ‘css_id’ => $id, */’class’ => $class/* , ‘width’ => ‘150px’, ‘height’ => ‘150px’ */ ) );

    printf( ‘

    ‘ . __(‘%1$s’, ‘fgroup’) . ‘

    ‘, $avatar );

    /* Display User-Defined Group Description */
    if ( $description )
    printf( ‘

    ‘ . __(‘%1$s’, ‘fgroup’) . ‘

    ‘, $description );

    /* Display Group Activity */

    if ( bp_has_activities (array ( ‘primary_id’ => $groupid, ‘max’ => ‘5’) ) ) : while ( bp_activities() ) : bp_the_activity();

    locate_template( array( ‘activity/entry.php’ ), true, false );

    endwhile; endif;

    wp_reset_query();

    /* After widget (defined by themes). */
    echo $after_widget;
    }

    /*** Update the widget settings. ***/
    function update( $new_instance, $old_instance ) {
    $instance = $old_instance;

    /*** Strip tags ***/
    $instance = strip_tags( $new_instance );
    $instance = (int) $new_instance;
    $instance = strip_tags( $new_instance );

    return $instance;
    }

    /*** Display widget setting controls on the widget panel. ***/
    function form( $instance ) {

    /* Default widget settings. */
    $defaults = array( ‘title’ => __(‘Featured Group’, ‘fgroup’));
    $defaults = array( ‘groupid’ => __(‘4’, ‘fgroup’));
    $instance = wp_parse_args( (array) $instance, $defaults ); ?>

    <label for="get_field_id( ‘title’ ); ?>”>
    <input id="get_field_id( ‘title’ ); ?>” name=”get_field_name( ‘title’ ); ?>” value=”” style=”width:100%;” />
    Default: Featured Group

    <label for="get_field_id( ‘groupid’ ); ?>”>
    <input id="get_field_id( ‘groupid’ ); ?>” name=”get_field_name( ‘groupid’ ); ?>” value=”” style=”width:100%;” />
    Find the ID in the Network Admin Dashboard under “Buddypress/Group Management”.

    <label for="get_field_id( ‘description’ ); ?>”>
    <input id="get_field_id( ‘description’ ); ?>” name=”get_field_name( ‘description’ ); ?>” value=”” style=”width:100%;” />
    Optional: Enter a description or leave blank.

    <?php
    }
    }`

    Any idea what’s going on? The favorites and comments work fine from the other pages, just not from my widget.

    Pepperbase
    Participant

    Hi,

    I’ve managed to setup a linkedin api to sync profiles. If the mystery man is displayed it gets replaced by the user’s linkedin avatar. However, I use the bp_before_profile_edit_content hook to display to linkedin sign in button. Therefor the linkedin avatar is only displayed on the edit page. How can I display the linkedin avatar on all pages? I guess I should use the filter bp_core_fetch_avatar, but I have no idea how.

    This is the code so far: http://pastebin.com/3dGdMFeV

    Thanks for any suggestions!

    #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.

    #125115
    r-a-y
    Keymaster

    You shouldn’t use the members loop if you don’t need it.

    A more efficient call is using bp_core_fetch_avatar() and setting the parameters there. (Make sure you use a function_exists() call if you use this approach.)

    You can alternatively filter get_avatar() as well using bp_core_fetch_avatar() as well.

    julien760
    Member

    hello,

    I try to do the same thing. I want to display a specific picture following the gender of the members.

    I use add_filter and the picture of the profil is the good one but all others pictures from sidebar, for example, are the same…

    Have you finally find a solution for this issue ?

    Thanks in advance,

    My test code :
    function bp_remove_gravatar ($image, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir) {
    $default = get_stylesheet_directory_uri() .’/images/bp_default_avatar.gif’;
    if( $image && strpos( $image, “gravatar.com” ) ){
    if ( bp_get_profile_field_data( ‘field=Gender’ ) == ‘Female’ ) {
    $default = get_stylesheet_directory_uri() .’/images/def_f_avatar.gif’;
    return ‘female‘;
    }
    if ( bp_get_profile_field_data( ‘field=Gender’ ) == ‘Male’ ) {
    $default = get_stylesheet_directory_uri() .’/images/def_m_avatar.gif’;
    return ‘male‘;
    }
    else {
    return $image;
    }
    } else {
    return $image;
    }
    }
    add_filter(‘bp_core_fetch_avatar’, ‘bp_remove_gravatar’, 1, 9 );

    #123242
    logixz
    Member

    @modemlooper understood, I was thinking that since that SQL queries pulls the userid I could somehow tie in bp_core_fetch_avatar into the equation?

    #119714
    modemlooper
    Moderator

    Found the avatar filters but not sure how to change it to display the associated group avatar.

    $object = apply_filters( ‘bp_get_activity_avatar_object_’ . $current_activity_item->component, ‘user’ );

    return apply_filters( ‘bp_get_activity_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $item_id, ‘object’ => $object, ‘type’ => $type, ‘alt’ => $alt, ‘class’ => $class, ‘width’ => $width, ‘height’ => $height, ’email’ => $email ) ) );

    EDIT: seems just changing user to groups will get the image.

Viewing 25 results - 176 through 200 (of 310 total)
Skip to toolbar