BuddyDev

Search

[Resolved] Display member type profile by color

  • Participant
    Level: Enlightened
    Posts: 26
    Ahmed on #9845

    Hi, I use member type pro and I want to customize my member type profile by displaying it by color, for exemple all member type teacher has blue color and student red color.
    Can I do it?
    Thanks!

  • Keymaster
    (BuddyDev Team)
    Posts: 24075
    Brajesh Singh on #9846

    Hi Ahmed,
    Thank you for asking.
    yes, it is doable. Are you comfortable with the css?

  • Participant
    Level: Enlightened
    Posts: 26
    Ahmed on #9851

    I’m not expert but yes 👍

  • Keymaster
    (BuddyDev Team)
    Posts: 24075
    Brajesh Singh on #9861

    Please put this in your bp-custom.php

    
    
    /**
     * Inject classes to body based on displayed user's member types.
     *
     * @param array $classes array of css classes.
     *
     * @return array
     */
    function buddydev_add_membertype_to_body_class( $classes = array() ) {
    
    	if ( ! bp_is_user() ) {
    		return $classes;
    	}
    
    	$member_types = bp_get_member_type( bp_displayed_user_id(), false );
    
    	if ( ! $member_types ) {
    		return $classes;
    	}
    
    	foreach ( $member_types as $member_type ) {
    		$classes[] = 'member-type-' . $member_type; // member-type-student etc.
    	}
    
    	return $classes;
    }
    
    add_filter( 'bp_get_the_body_class', 'buddydev_add_membertype_to_body_class' );
    
    

    Now the pages for displayed users will have the class “-member-type-student”(Last part is the actual name of the member type) applied to body.

    You can do the color changes etc bade on that.

    PS: I will be including it in next update of member types pro plugin too.

    Hope that helps.
    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 26
    Ahmed on #9862

    thank you very much Brajesh.

    I’m looking forward to the update.
    you do a great job, bravo

    Ahmed.

  • Participant
    Level: Enlightened
    Posts: 26
    Ahmed on #9863

    sorry Brajesh, one more question, if i want to add this class in member directory, how i do that?

    • This reply was modified 6 years, 7 months ago by Ahmed.
  • Keymaster
    (BuddyDev Team)
    Posts: 24075
    Brajesh Singh on #9865

    Thank you.
    On the directory page, BuddyPress already ads the class like “member-type-{$member_type_name}” e.g member-type-student etc to the list item class.

  • Participant
    Level: Enlightened
    Posts: 26
    Ahmed on #9866

    thank you

The topic ‘ [Resolved] Display member type profile by color’ is closed to new replies.

This topic is: resolved