BuddyDev

Search

[Resolved] Insert 'Member Type' in the Title of Member Directories

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #9018

    Hi!

    I am using ‘BuddyPress Member Type Generator’ plugin to generate 3 types of members. ‘Students’, ‘Teachers’, ‘Guardians’. Now, I have 3 directories of members

    mtsite-com/members/type/students/ (can these urls be customized / shorten?)
    mtsite-com/members/type/teachers/
    mtsite-com/members/type/guardians/

    Current meta title of all 3 directories same ‘Memebers – MySite’. I wish to insert the actual member type in title to make it for example :

    ‘Students – MySite’ OR ‘Students – Members – MySite’ (First is preferable)

    Please help me with this

    Thank you very much

  • Keymaster
    (BuddyDev Team)
    Posts: 21463
    Brajesh Singh on #9021

    Hi Lavish,

    Thank you for using the BuddyPress Members Type plugin.

    For member type directory title, since BuddyPress currently does not support it, you can put the following in your bp-custom.php to make it work

    
    
    /**
     * Modify members directory title for the member types
     *
     * @param array $title title parts
     *
     * @return array
     */
    function bpdev_modify_page_member_directory_title( $title ) {
    
    	if ( ! bp_is_members_directory() ) {
    		return $title;
    	}
    
    	$member_type = bp_get_current_member_type();
    
    	if ( ! $member_type ) {
    		return $title;
    	}
    
    	$type_object = bp_get_member_type_object( $member_type );
    
    	$sep = apply_filters( 'document_title_separator', '-' );
    
    	$title['title'] = $title['title'] . ' ' . $sep . ' ' . $type_object->labels['singular_name'];
    
    	return $title;
    }
    
    add_filter( 'document_title_parts', 'bpdev_modify_page_member_directory_title', 1000 );
    
    

    Hope that helps.

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #9022

    Hello Brajesh!

    It is flawless! The only issue is, it inserts ‘singular’ label. Can I get plural? I tried by changing ‘singular_name’ to ‘plural_name’ but that did not work.

    Thank you very much

  • Keymaster
    (BuddyDev Team)
    Posts: 21463
    Brajesh Singh on #9041

    Hi Lavish,
    You can change

    
    $type_object->labels['singular_name']
    

    to

    
    $type_object->labels['name']
    
    

    In the above code to do that.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #9051

    Perfect! 🙂

    Can you tell me where can I change ‘Viewing members of the type’ to ‘Viewing profiles of the type’? I was looking for the phrase in po files for the translation but couldn’t locate it.

    And can the url be changed from “/members/type/teachers/” to “/members/teachers/” or even better “/teachers/”?

    Many thanks

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #9067

    I have changed the phrase by updating my buddypress-en_US.po file. The old file did not have that phrase.

    Only question that remains now is how to shorten the url of the member type directories to my-site.com/membertype

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 21463
    Brajesh Singh on #9085

    Hi Lavish,
    I am sorry but you can not do that. BuddyPress does not support that yet.

    A possible solution will be to create a custom page template with member loops. The url aesthetics may not be worth the time though.

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #9096

    I understand. Thank you for all the help!

  • Keymaster
    (BuddyDev Team)
    Posts: 21463
    Brajesh Singh on #9106

    Thank you.

The topic ‘ [Resolved] Insert 'Member Type' in the Title of Member Directories’ is closed to new replies.

This topic is: resolved