BuddyDev

Search

[Resolved] Display last name in profile pages

Tagged: ,


  • Participant
    Level: Enlightened
    Posts: 38
    Javier on #4188

    Hello!

    Has anyone been able to display the user last name in the profile page? I mean, there’s a default xProfile field for the first name (which gets ‘first_name/display_name’ user registration field); but I can’t find a way to get ‘last_name’. I’ve read some threads on this, but still can’t find a way.

    Appreciate any guidance.

    Best
    Javier


  • Keymaster
    Level: Guru
    (BuddyDev Team)
    Posts: 894
    Ravi on #4189

    Hi Javier,

    Here some example code to display the full name of user in the profile. But You can manipulate user name value using the user id. Let me know if it works for you or not.

    
    function buddydev_modified_user_profile_name( $name ) {
    
        $user_id = bp_displayed_user_id(); // You can Manipulate $name value using this user id
    
        $name = bp_get_displayed_user_fullname();
    
        return $name;
    
    }
    add_filter('bp_get_displayed_user_mentionname', 'buddydev_modified_user_profile_name');
    
    

    Thank You
    Ravi


  • Participant
    Level: Enlightened
    Posts: 38
    Javier on #4190

    Hi Ravi,

    I’m testing your code, but can’t see any change.
    I guess my question is confusing, I’ll try to clarify: if you register an user (from wp-admin/wp-users.php) there are Username (stored in wp_users db table), First Name and Last Name (both stored in wp_usermeta). My guess is that BuddyPress “syncs” ‘First Name’ with an extended profile field called ‘Name’; but does nothing with ‘Last Name’.

    Thank you
    Javier


  • Keymaster
    (BuddyDev Team)
    Posts: 13884
    Brajesh Singh on #4191

    Hi Javier,
    Thank you for clarifying.

    Please give a try to this plugin

    https://wordpress.org/plugins/bp-xprofile-wp-user-sync/

    That will do it for you.

    Hope that helps.


  • Participant
    Level: Enlightened
    Posts: 38
    Javier on #4202

    Thank you, Brajesh.

    That plugin is working except for users that were registered before its installation. I’m checking and will post the results here.

    Regards
    Javier


  • Participant
    Level: Enlightened
    Posts: 38
    Javier on #4269

    Hello,

    Finally I could not sync last name with users registered before “BP XProfile WordPress User Sync”: you have to update user’s data in order to make plugin work.
    So my advice here is to install the plugin before adding users (especially if you are going to add a fairly amount, which was my case).


  • Keymaster
    (BuddyDev Team)
    Posts: 13884
    Brajesh Singh on #4281

    Hi Javier,
    Thank you for the update. Yes, you are right about it. Though it is possible to write a script that does it for the older registrations, It does not seem to be readily available.

    Marking the thread as resolved. Please do post a topic if you need any help in future 🙂

You must be logged in to reply to this topic.

This topic is: resolved
Subscribe