Change profile field name when viewing other member's profile

Home Forums Gwangi – Dating & Matchmaking Community Theme Popular Features Member Profile Change profile field name when viewing other member's profile

This topic contains 10 replies, has 2 voices, and was last updated by  Themosaurus 5 months, 1 week ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #4924

    Malas Reda
    Participant
    • 15 Posts
    @malasreda

    Hello,

    I have many fields on the register page. We can find those informations in the profile section for logged-in user also.

    When the logged in user see other members profile, he can also see those information but i would like to change the name of the fields only for other members when logged in.

    Exemple:
    – On registration page : “what are you looking for ?”
    – On Logged-in user profile page : “what are you looking for ?”
    – When the logged-in user check other members profile : “Is looking for”

    Is it possible ?

    Thank you,

    #4927

    Themosaurus
    Keymaster
    • 1673 Posts
    @themosaurus

    Hi @malasreda,

    Here is a code snippet that might help you:

    add_filter( 'bp_get_the_profile_field_name', 'gwangi_change_profile_field_name' );
    function gwangi_change_profile_field_name( $field_name ) {
    
    	if ( bp_is_user_profile() && ! bp_is_my_profile() ) {
    		switch ( $field_name ) {
    			case 'What are you looking for':
    				return 'Is looking for';
    				break;
    			case 'Other field':
    				return 'New name for other field';
    				break;
    		}
    	}
    
    	return $field_name;
    }

    Don’t forget to change the field names by your own. If you need to change more field names, you can also duplicate this part as many times as you need:

    case 'Other field':
    	return 'New name for other field';
    	break;

    As a reminder, if you need to find out how to add a PHP code snippet to your site, we recommend that you visit this article of our documentation:

    Adding Custom PHP Without Changing Your Child Theme

    Regards,

    #4938

    Malas Reda
    Participant
    • 15 Posts
    @malasreda

    Perfect it is working !

    I need to put a new field wich is “Bio”. The user will fill text for his profile.

    This field is only visible on the profile page and not on the registration page.

    How can i do this ?

    #4969

    Malas Reda
    Participant
    • 15 Posts
    @malasreda

    PS: The field will be created in another group field.

    #4971

    Themosaurus
    Keymaster
    • 1673 Posts
    @themosaurus

    The registration form will only display fields that are in the “Base (Primary)” field group. That means if you create a new field group, all the field in that group will be displayed only in your profile.

    To create new field groups, go to Users > Profile Fields then click “Add New Field Group” at the top of the screen. When your new field group has been created, you can create your “Bio” field in that new group.

    Best regards,

    #4981

    Malas Reda
    Participant
    • 15 Posts
    @malasreda

    This step is done.

    Now i need to show this fiels on the profile page of each member under the profile section. And if i was the logged in user i should be able to modifie this field like the other registration field.

    Is it possible ?

    #4989

    Themosaurus
    Keymaster
    • 1673 Posts
    @themosaurus

    Hi @malasreda,

    If you have correctly created your field group and your Bio field, it should already be displayed in member profiles. If it is not displayed, can you please try to edit the field and check the “Visibility” panel on the left to see if it is visible to members?

    If it still doesn’t work, can you please create an account with administration access and share the credentials with us so that we can take a look directly on your website? Don’t forget to check the “Set as private reply” box in your next reply if you share credentials with us, so that only you and us can see your reply.

    Best regards,

    #4993

    Malas Reda
    Participant
    • 15 Posts
    @malasreda

    Oh thank you it works !

    Under the “active il y a 3 min” we see the recent activity of every profile. I need to replace this by the bio field of every member! and if i am the user logged in and don’t have a bio yet,by default i want to show a link : “No bio yet, describe yourself here ” and on click they will land on the profile section to modify the bio field (the page in the screenshot).

    Is this possible ?

    #5007

    Themosaurus
    Keymaster
    • 1673 Posts
    @themosaurus

    Hi @malasreda,

    You’re welcome, glad that we could help you 🙂

    Unfortunately replacing latest activity with the bio is more complicated and we don’t have any snippet that we could share with you for that.

    If you are familiar with modifying themes however, I can tell you that this is located in gwangi/buddypress/members/single/cover-image-header.php on line 131 in your Gwangi theme.

    Please be aware that if you do modify Gwangi, your modifications will be lost if you update it later.

    If you are not familiar with theme modifications, we recommend you to require the services from Envato Studio freelancers (https://studio.envato.com/explore/websites-programming). This web platform gives you access to developers who have already experience with theme customizations, and for very competitive prices.

    Best regards,

    #5048

    Malas Reda
    Participant
    • 15 Posts
    @malasreda

    Hello,

    I used this snippet you gave me and it works perfectly,

    add_filter( 'bp_get_the_profile_field_name', 'gwangi_change_profile_field_name' );
    function gwangi_change_profile_field_name( $field_name ) {
    
    	if ( bp_is_user_profile() && ! bp_is_my_profile() ) {
    		switch ( $field_name ) {
    			case 'What are you looking for':
    				return 'Is looking for';
    				break;
    			case 'Other field':
    				return 'New name for other field';
    				break;
    		}
    	}
    
    	return $field_name;
    }

    If i want to change the fields name in the search profile directory filters which snippet should i use ?

    Thank you

    #5059

    Themosaurus
    Keymaster
    • 1673 Posts
    @themosaurus

    Hi @malasreda,

    No need for another snippet to do that 🙂

    From your admin dashboard, you just have to go to Users > Profile Search. Open the search form that is used in your member directory, and there you can change the “Label” and “Description” for any of your fields.

    Best regards,

Hi there,

This topic has been inactive for a while now so we will be closing it to keep the forum tidy. Don't hesitate to create a new topic if you still need help and we'll be glad to help you!

Best regards,
The Themosaurus team.

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Change profile field name when viewing other member's profile’ is closed to new replies.