BuddyDev

Search

[Resolved] Change or remove member type from slug

Tagged: ,

  • Participant
    Level: Initiated
    Posts: 3
    Pieter Bas on #38002

    Hello,
    is there a way to change or remove the member type from the directory slug?
    meaning, remove or change [type] in this example: http://www.examlpe.nl/members/type/men/

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #38042

    Hello Pieter,

    Thank you for posting here. we can not remove this.

    Try the following code to change:

    
    add_filter( 'bp_members_member_type_base', function( $base ) {
    
    	// Replace custom with your desired string.
    	return _x( 'custom', 'member type URL base', 'buddypress' );
    } );
    
    

    If not works. Please do let me know with the environment you are working with i.e. BuddyBoss or BuddyPress

    You can place this code in ‘bp-custom.php’ file.

    https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Regards
    Ravi

    • This reply was modified 3 years, 7 months ago by Ravi.
  • Participant
    Level: Initiated
    Posts: 3
    Pieter Bas on #38051

    Hi Ravi,

    Great, it worked! Thanks so much for your help!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #38054

    Hello Pieter,

    Thank you for the acknowledgment. I am glad that I could help.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 14
    Cordial on #52512

    I followed this your code, and it worked– because my Organisation has branches in different locations:
    — Ikeja.
    — Victoria Island.
    — Lekki.

    These are not Member Types, but Locations: so your code helped me to call them “Locations”– as what they are, as you can see here — https://prnt.sc/l0ypmQxEGzSP

    2.) You will notice that in my screenshot, when I want to view members of a specific directory who belong to a specific location, it says “Viewing members of the type: Maryland”.

    Now, Maryland is a location. Instead of using the word/text “Type”, I want that text to say “Location”– so that it becomes “Viewing members of the location: Maryland”.

    You have any PHP Code Snippet that can help me change that Text from “Type” to “Location” ?

    Regards.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52515

    Hello Cordial,

    Thank you for posting. You can use any translation plugin to achieve this. Just locate the string “Viewing members of the type” and change over there.

    You can refer the following plugin:

    https://wordpress.org/plugins/loco-translate/

    Please let me know if you face any issue with this.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 14
    Cordial on #52566

    Hello Ravi,

    I thank You very much for this reply, even though I’m not satisfied with the reply.

    You see, I have achieved so much on the website with custom code from everywhere— from BuddyPress Forum, to random developers code found during Google Search, and also from you guys at BuddyDev.

    The use of custom code was because I had performance in mind, and didn’t want too much plugins flooding my website– where there could be compatibility issues over time.

    It now pains me, that you want me to use a plugin, simply because of this single one line of text.

    Please, let’s not go that route.

    If it’s you that wants to do what I’m asking, you will not use plugin for that small thing. I know you will use code to translate the string.

    Please help me find the code snippet that can change that single line of text.

    Now, I don’t mind even going to BuddyPress Template and changing it.

    The issue is that I don’t know where in the template, that line of text is located.

    Please, help me out here, without any extra plugin.

    Regards.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52568

    Hello Cordial,

    Thank you for your reply and for sharing your concerns. I understand the importance of maintaining optimal performance and minimizing the use of plugins. I have suggested the plugin because not only can you modify the mentioned string but in future, if you want to modify another string from any other plugin that supports localization, you could also modify that. To modify the string using custom code use the following:

    
    
    add_filter( 'bp_get_current_member_type_message', function ( $message ) {
    	$type_object = bp_get_member_type_object( bp_get_current_member_type() );
    
    	$message = sprintf( __( 'Viewing members from the location: %s', 'buddypress' ), '<strong>' . $type_object->labels['singular_name'] . '</strong>' );
    
    	return $message;
    } );
    
    

    Please try it.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 14
    Cordial on #52593

    The code worked perfectly, as you can see here– https://prnt.sc/zLu7zoZVnAzQ

    Thanks so much for this, Sir!

    MOVING FORWARD
    I reasoned the Loco Translate suggestion you brought up, and that seemed to steer me up to understand that, the Text in focus, must be somewhere inside BuddyPress.

    Through some Googling, I found BuddyPress on Github, and realized that the Text is on this file path ( buddypress/src/bp-members/bp-members-template.php ).

    1.) The Text is inside the ( bp-members-template.php ), and it is located on line 2263, as you can see here— https://prnt.sc/K8lMFIkUEoTt

    I’m wondering if that is how I can find the file location through the File Manager of my Control Panel?

    2.) Suppose I find that file, can I edit the Text directly from there? — without breaking my website?

    Why I’m asking, is to know if some other functions don’t work based on that text remaining as “Type” in the Template? — in which case, if the Text changes from being “Type”, some things may fail?

    2b.) And if I edit the Text directly from there, would the edits be lost whenever I update BuddyPress?

    Regards.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #52595

    Hi,

    1. Yes, or you can search inside the file manager.
    2. Yes, but a very bad idea to do so.

    You are favouring premature optimization and perceived performance over a huge maintenance nightmare. Your edits will be lost when BuddyPress update happens in future.

    PS:- You do not need loco translate, you can use any localization toool(e.g poedit) to change the text and generate the file. WordPress supports localization out of the box.
    https://developer.wordpress.org/plugins/internationalization/localization/

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved