Avatar tweak

  • Participant
    21million on #48586

    In Buddyboss I’d like for each user’s avatar to have a border color according to his member type. In this way it will be easier to tell in which category users are in. For example: pink rim around girls’ avatars, blue for boys, red for admins. Can anybody please set me in the right direction? Thanks in advance

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2986
    Ravi on #49267


    Thank you for posting. Please try the following code in your “bp-custom.php” file.

    // modify BuddyPress avatar class with member type
    add_filter( 'bp_core_avatar_class', function ( $classes, $item_id, $object ) {
    	if ( 'user' !== $object ) {
    		return $classes;
    	$member_type = bp_get_member_type( $item_id );
    	if ( $member_type ) {
    		$classes .= ' member-type-' . $member_type;
    	return $classes;
    }, 10, 3 );

    It will add a member-type specific class with an avatar then you can apply CSS rules to it.

    Note: Please refer to the following URL for more info on the bp-custom file


You must be logged in to reply to this topic.

This topic is: not resolved