BuddyDev

Search

[Resolved] BuddyPress Member Types Pro Directory pages

  • Participant
    Level: Initiated
    Posts: 18
    Nancy Ketola on #44146

    Hi-

    Great plugin! I have 10 different member types and each type has its own directory and search filters on the right-hand side. For example:

    https://domain.com/members/type/student
    https://domain.com/members/type/teacher

    What I would like to do, is for each filter area, add CSS (display:none;) so that I can delete some of the filters that are not relevant to that member type. Generally, in CSS, you can single out individual pages by using a (for example .post-id-599) and indicator of that page.

    In order to find the page or post ID, I just mouse over the page and in the bottom left, you can get the ID. My question here is, how can I do this for each directory page? How do I find the ID of each member directory so that I can apply CSS to specific to that directory.

    Thank you so much!

  • Participant
    Level: Initiated
    Posts: 18
    Nancy Ketola on #44169

    Hi-

    I am wondering if you have any input on this? Thank you!

  • Keymaster
    (BuddyDev Team)
    Posts: 21814
    Brajesh Singh on #44176

    Hi Nancy,
    Thank you for the question.
    I am sorry, I could not assist earlier.

    By default, BuddyPress does not add any distinguishing classes for specific member type.

    You may add following code in your child theme’s functions.php or in wp-content/plugins/bp-custom.php or use a snippet manager to add it.

    
    /**
     * Appends bp-member-type-{member-type-id} to body.
     */
    add_filter( 'bp_get_the_body_class', function ( $classes ) {
    
    	if ( ! bp_is_members_directory() ) {
    		return $classes;
    	}
    
    	$member_type = bp_get_current_member_type();
    
    	if ( $member_type ) {
    		array_push( $classes, 'bp-member-type-' . esc_attr( $member_type ) );
    	}
    
    	return $classes;
    } );
    
    

    It will append a class specific to each member type on the member directory.

    For example, for ‘teacher’, the class will be ‘.bp-member-type-teachers’ and do on.

    Hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 18
    Nancy Ketola on #44194

    This worked perfectly! Thank you so much. For those of you reading this ticket, the above code provided allowed me to then make separate directories by Profile Type and have the default BP search bar. I entered all of the search fields, and then I used CSS to make the ones I didn’t want in each directory. Provides a way to make an ajax searchable directory for each profile type.

    THANK YOU

  • Keymaster
    (BuddyDev Team)
    Posts: 21814
    Brajesh Singh on #44209

    Hi Nancy,
    Thank you for the reply and sharing your insights. It will help others too.

    I am glad I was able to assist.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved