BuddyDev

Search

[Resolved] Having name and last name in post and header

  • Participant
    Level: Enlightened
    Posts: 130
    giuseppe on #44264

    Hello,

    I need member to have name and last name in any post because where only name is showed, and the same on
    header (it was there but there is an issue. Please read).

    As the last name is not present in the profile fields I have changed the field “cognome” as text with the “last name” so it is in sync with wordpress and the plugin “Force First and Last Name” works. (I’ve read that this plugin seems unuseful starting from Buddypress 8.0 and I have 10.0 but there is no way for the admin to set “first and last name” for everybody as mandatory). Without the plugin the “cognome” field is not registered in the wordpress field (infact the field in wordpress remains empty and the “Force…” plugin shows automatically the nicename, that is deleted in css customization.

    So, this way it works but non completely:

    1. To show first and last in post I need to push the buttom in Force First and Last Name because it does not work with new registered.

    2. Before the plugin, I already had the first name and last name in the header of the member and now there is only the name. For a strange reason the admin shows in the header first name and last name and are fully showed on one line, that is exactly what I’d like to have for all members (before I had both first and last but on two lines).

    How could I set the name and last mandatory for everybody, having them on the header better if on only one line?

    As you can imagine these requests comes for a first set of everything, after that I will not be so present with requirements.

    Thank you very much,

    Giuseppe

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

    Hello Giuseppe,

    Thank you for posting. Have you tried our plugin BuddyPress Profile Completion which allows site admin to force things like profile fields, profile photo and profile cover as mandatory for users?. You can use this plugin and mark First Name and Last Name as required then under plugin settings enable the required field for the user. If the user has not provided the details he will be forced to complete the required fields first in order to continue.

    Have a look:
    https://wordpress.org/plugins/buddypress-profile-completion/

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 130
    giuseppe on #44267

    Hello Ravi,

    thank you.

    I have done but it does not work and the problem seems to be that “last name” in registration (I use branded login) is not sync with wordpress. Precisely, in the profile tabs there is only “name” in sync and not deletable, while last name “cognome” is not in sync with wordpress.

    How can I fix?

    Thank you,

    Giuseppe

  • Participant
    Level: Enlightened
    Posts: 130
    giuseppe on #44269
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 130
    giuseppe on #44272

    Hello,

    I have deactivated Wbcom plugin that shows xfields on header because it show the last name (“cognome”) only if indicated as text and not as the last name (and in this case it’s not possible to have the full name on the post). Wbcom says that if the Xfield is visible in the plugin it should be visible, but it is not when is set correctly as last name.

    So I have tried with this code added as a snippet:

    function add_member_meta_data_profile() {
    $Provincia = bp_get_member_profile_data(‘field=Provincia’);
    $Cognome = bp_get_member_profile_data(‘field=Cognome’);
    $Categoria_negozio_o_impresa_locale = bp_get_member_profile_data(‘field=Categoria_negozio_o_impresa_locale’);
    $Mi_presento = bp_get_member_profile_data(‘field=Mi_presento’);
    $Situazione_sentimentale = bp_get_member_profile_data(‘field=Situazione_sentimentale’);

    echo ‘<p class=”mdetcenter”>’. ‘Provincia : ‘ . $Provincia . ‘</p>’;
    echo ‘<p class=”mdetcenter”>’. ‘Cognome : ‘ . $Cognome . ‘</p>’;
    echo ‘<p class=”mdetcenter”>’. ‘Categoria negozio o impresa locale : ‘ . $Categoria_negozio_o_impresa_locale . ‘</p>’;
    echo ‘<p class=”mdetcenter”>’. ‘Mi presento : ‘ . $Mi_presento . ‘</p>’;
    echo ‘<p class=”mdetcenter”>’. ‘Situazione sentimentale : ‘ . $Situazione_sentimentale . ‘</p>’;
    }
    add_action(‘bp_profile_header_meta’, ‘add_member_meta_data_profile’);

    but only Provincia is showed correctly.

    Very frustrating and not understandable.

    Any suggestion?

    Thank you,

    Giuseppe

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

    Hello Giuseppe,

    Thank you for sharing the details. Please let me know are you looking to show the First Name and Last Name of the user on the activity page. I have checked the activity directory or your site and it is showing me both the first and last names of the user. Can you share the screen shots or your issue?

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 130
    giuseppe on #44286

    Hello Ravi,

    thanks for your help.

    Sure. I explain better. Please consider that my scopes are 1. to have name and last name showed on the member posts and 2. have name and last name showed on header.

    When a new member register here http://www.amodio.live/registrazione (I put this link because it’s possible that the form counts something in this strange situation) only the name is on the post as you can see here:

    https://ibb.co/dpvGtB4

    Then I have two choices:

    1. A. I use the “cognome” (last name) field in sync inside the user field selecting the sync and B. I go to the Force plugin, push the buttom (it does not work with new member), update the existing member having the name and last name (but in this case the Wbcom plugin does not “see” for some reason the “cognome” (last name) and omit it on the header).

    or

    2. I do not sync the field “cognome” (last name) with wordpress, it is only a text field, so I have it as xfield with the Wbcom plugin but, of course, Force plugin does not see the last name and, even if you push the update, it does not work.

    Solution:

    1. I do sync “cognome” (last fields). 2. I use Force to have name and last name and 3. I use the snippet to fill the header but: 1. Clicking update on Force everyday is not the maximum and 2. the snippet to publish data on header is not working.

    I hope the scope and the issues are clearer now.

    Thanks for your help,

    Giuseppe

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

    Hello Giuseppe,

    Thank you for your explanation. As per my understanding, you are looking at something like this:

    https://www.awesomescreenshot.com/image/25216651?key=272e8011145b93da19bfa054cea4cd1e

    If yes,

    Try the following code:

    
    /**
     * Before activity post form.
     */
    function buddydev_before_activity_post_form() {
    	add_filter( 'bp_get_user_firstname', 'bp_get_loggedin_user_fullname', 10, 2 );
    }
    add_action( 'bp_before_activity_post_form', 'buddydev_before_activity_post_form' );
    
    /**
     * After activity post form.
     */
    function buddydev_after_activity_post_form() {
    	remove_filter( 'bp_get_user_firstname', 'bp_get_loggedin_user_fullname', 10 );
    }
    add_action( 'bp_after_activity_post_form', 'buddydev_after_activity_post_form' );
    
    

    Please let me know if anything wrong.

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 130
    giuseppe on #44290

    Hello,

    I need to have name and last name on both: member post AND haeder.

    Regarding member post I have added your code as snippet and it does not work: https://ibb.co/yWTdyh1 (but you can see that the last name (cognome) is on the header).
    This happens because the User Field “Cognome” is not in sync with wordpress as you can see here:
    https://ibb.co/hcVnP9W (it is indicated that is only “text” field NOT as “cognome” that put the field in sync with wordpress.

    If you put the User field on “cognome” it will sync the “cognome” (last name) in wordpress so we can have name and last name on buddypress member BUT it will disappear on header and from another research plugin. Here you can see the field “cognome”, but if you sync the User field it will disappear. https://ibb.co/whMFw86 .

    So, having name and last name BOTH on member post AND header is the problem, and the origin of the problem seems to have in the User Field. There is something that, when you Sync the “cognome” (last name) field in user field, you let it to be showed on member post (that is obvious because what is showing are the name and last name as registered in wordpress by bp) but at the same time the sync setting in the “cognome” user field HIDE the field to all the other plugin needed and to be showed on header with a snippet too.

    Why this happens? I don’t know.

    How could be fixed? I ask because fixing the sync issue seems to be the only way to have name and last name on BOTH member post and header.

    Many thanks,

    Giuseppe

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #44299

    Hi Giuseppe,
    Thank you for your posts.

    I will be assisting you from here on on this topic. I have gone though all of your posts and your site.

    I am unable to understand much on the site due to language(is that Italiano?), so that is a cognitive barrier for me while assisting you.

    Is this what you are looking for:-

    1. Have 2 fields for name( First name and last name)
    2. Use the combination of these fields at places where name is being used?

    I am not sure if you are using a plugin or code but if you are using one, you should disable the plugin and code before proceeding.


    BuddyPress does have the ability to specify the first name/last name but it is not used for display purpose.

    BuddyPress uses the Full name field for display purpose and this may feel unnatural at times.

    If you really want to have 2 fields for name(first name and last name ) and need them to be used for updating display name,there is no way in BuddyPress to do that unless the full name field is hidden.

    Here is what might work for you.

    1. In the first field group, Create 2 fields and mark them as first name/last name from BuddyPress Field type selection->WordPress Fields->Text, mark these fields as required(since you want them to be filled).

    2. Use the suggestion of the user syn plugin author to hide the actual full name/disply name field

    https://wordpress.org/support/topic/bp-8-0-name-field/
    https://gist.github.com/christianwach/06d878edc277ce1ca8a7e59a82052744

    Now, the full name field is hidden, the first name and last name will be used to update it.

    This will have no effect on your existing users. It will only have affect on the new user registering/updating their profile.

    Hope that helps.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved