BuddyDev

Search

[Resolved] Change default avatar issue

  • Participant
    Level: Initiated
    Posts: 3
    jafar bagheri on #39869

    Hi,

    I have visited the links below for more guidance but the code below still does not work. I’ve added two png images in the assets folder in the theme child directory (buddyboss) and use this code:

    add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
    
    function buddydev_set_default_use_avatar_based_on_member_type( $avatar, $params) {
        $user_id = $params['item_id'];
    
        $type = bp_get_member_type( $user_id );
    
        if ( $type == 'club' ) {
            $avatar = get_template_directory_uri() . '/assets/images/profile.png';
        } elseif( $type =='student' ) {
            $avatar = get_template_directory_uri() . '/assets/images/profile2.png';
        } else {
            $avatar = get_template_directory_uri() . '/assets/images/profile2.png';;
        }
    
        return $avatar;
    }
    
    

    This was the forum I referred to
    https://buddydev.com/using-different-default-avatar-buddypress-users-based-profile-fields-member-type/

    Thanks in advance

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #39874

    Please try changing ‘get_template_directory_uri’ to ‘get_stylesheet_directory_uri’ if you are putting it in the child theme.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #40324

    Hi,
    I hope it worked. marking resolved due to lack of replies.

    Regards
    Brajesh

The topic ‘ [Resolved] Change default avatar issue’ is closed to new replies.

This topic is: resolved