Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to use full name, first name + last name


  • peterverkooijen
    Participant

    @peterverkooijen

    At the moment Buddypress/WP MU makes it very hard, perhaps impossible, to flexibly use member’s real names or other data (companyname, city) in the site or have something like ‘Hello John’ in email notifications.

    As default the full name is stored in one field, instead of as seperate first name and last name. This also kinda encourages new members to just fill out their first name or some BS pseudonym – I know this from my current home-baked site.

    I have no clue how to retrieve the full name from the database. It’s not in the regular wp_users table, but in two other related tables. I guess this requires serious PHP/MySQL coding and I can’t find any clear examples anywhere.

    Default Buddypress is fine for teens/tweens who want to use their anonymous username, but it’s not suitable for a more grown-up business network, for example.

    I’ve found this excellent plugin that allows members to login with just their email address and password. It doesn’t automatically make the required changes to the notification emails etc. though.

    Are there plugins that can fix these issues?

    Are there custom sql/php code examples how to retrieve and use basic member info?

    Are there tags or pieces of code that I can use site-wide for common things like the logged-in member’s real name?

Viewing 25 replies - 1 through 25 (of 29 total)

  • Jeff Sayre
    Participant

    @jeffsayre

    I assume you’re specifically talking about customizing a BuddyPress template. If so, then you need to look in the BuddyPress profiles tables in MySQL.

    For instance, the field definition for the “Full Name” field is stored in the wp_bp_xprofile_fields table and any corresponding datum is stored in the wp_bp_xprofile_data table.

    With respect to this:

    At the moment Buddypress/WP MU makes it very hard, perhaps impossible, to flexibly use member’s real names or other data (companyname, city) in the site or have something like ‘Hello John’ in email notifications.

    That is not true. Any piece of stored data can be accessed and spit out in any number of ways. It just must first be in the database. Look in the bp-xprofile.php file and the bp-xprofile subdirectory for a number of functions that can be called to extract a user’s data.

    By the way, I did see your other post about this topic and it was answered appropriately. With the default WPMU and BuddyPress setup, you will not be able to use a user’s full name until they’ve entered that data. They will not be able to enter their full name until after they register.

    So, unless you hack the wp-signup.php or register.php files, and require that a full name be provided when registering, you will not be able to send them a welcome email with their full name since that piece of data does not yet exist.

    All of what you are asking is possible but requires either a pre-existing plugin, a custom hack, or your ability in customizing and coding a BuddyPress template.


    Jeff Sayre
    Participant

    @jeffsayre

    Specifically, look at the file profile-loop.php and how it calls various functions to retrieve user profile data.


    peterverkooijen
    Participant

    @peterverkooijen

    So, unless you hack the wp-signup.php or register.php files, and require that a full name be provided when registering…

    That’s what I want then. I thought it already was a required field in the Buddypress registration. Anyway ‘Dear User’ is not acceptable. There must be a way to get the full name from sign-up in there. That’s how most professional sites do it.

    I’ll look into profile-loop.php. Thanks for that pointer.

    Buddypress/WPMU just makes it really hard for someone who’s not a real PHP-programmer to add/retrieve additional member data. In my old home-baked site there’s one table with all member data (name, company, city, etc.) and straightforward queries.

    Where should I start when I want replicate something like that in Buddypress?

    Any piece of stored data can be accessed and spit out in any number of ways.

    How? Is it all hardcore PHP programming from scratch? Are there code examples anywhere? Documentation that explains how to do it?


    nicolagreco
    Participant

    @nicolagreco

    if i’m not wrong, the Full Name has a filter, if you use it, you could replace it with the wp built-in name & last name, or use xprofile fields fot that,

    it depends on your php & wp skills :)


    peterverkooijen
    Participant

    @peterverkooijen

    Thanks Nicola Greco, but how? Where do I start? Where is this built-in “name & last name” feature? What keywords should I do a search on? What’s a filter?

    Please give me something to work with. I can figure a lot out by myself, but I have to approach it from a different angle than an experienced PHP programmer.

    Has no one else done this? Aren’t there examples how to do this anywhere?


    nicolagreco
    Participant

    @nicolagreco

    search in https://codex.wordpress.org/ , for filters, and user metas

    anyway if you’ve never developed with wp code it might be difficult


    Mike Pratt
    Participant

    @mikepratt

    Why don’t you just add two additional profile fields (last name & first name) , make them required so they show up on registration and then write a custom function to tweak the sign up email?

    btw, this is standard across a lot of social media sites. Look at Facebook – aside from the fact that they login with email instead of username, they also have display name, first and last….just like BP can have. Make FullName your Display name.


    peterverkooijen
    Participant

    @peterverkooijen

    Why don’t you just add two additional profile fields (last name & first name) , make them required so they show up on registration and then write a custom function to tweak the sign up email?

    Yes, that’s what I want to do. But how would that work?

    I’d already tried editing wpmu-functions.php, replace ‘Dear User’ with ‘Dear DISPLAYNAME’ and then add this line:

    \’$welcome_email = str_replace( “DISPLAYNAME”, $user->display_name, $welcome_email );\’

    But the display_name field in wp_users has the username, not the full name. Full name and other profile fields are in wp_bp_xprofile_fields + wp_bp_xprofile_data. I have no clue how to get them from there.

    Is it possible to write a function to retrieve full name (or first + last) from wp_bp_xprofile_data and put the result in the email? How does that work? Can you point me to a code example that shows the basic principles?


    Mike Pratt
    Participant

    @mikepratt

    I’m sure you can but I haven’t looked at xprofile_fields just yet. A bunch of other problems to solve. Burt Adsit might be able to help


    Burt Adsit
    Participant

    @burtadsit

    This thread has an example of how to build a filter: https://buddypress.org/forums/topic.php?id=2146 for the user full name.

    https://codex.wordpress.org/Plugin_API for docs on wp actions and filters.

    You should really talk to DJPaul here on the forums. He has a plugin called Welcome Pack that assigns new users a default friend and default group. He also says that the next version of that plugin will have the ability to create a custom welcome message to the new user. Not sure if that’s a PM or an email. Suggest what you want to him. He’s working that kinda track.

    https://buddypress.org/developers/DJPaul/

    https://wordpress.org/extend/plugins/welcome-pack/


    peterverkooijen
    Participant

    @peterverkooijen

    Thanks again for the useful info Burtadsit! :-)


    peterverkooijen
    Participant

    @peterverkooijen

    Following Mike Pratt’s suggestion I’ve added custom profile fields for separate first name and last name and made them required.

    They now show up on the registration form, but there’s already the required field “Name” there.

    Is there a way to autogenerate “Name” from “first name” and “last name”?

    Aren’t separate first name and last name already a default part of the system somewhere? I noticed user management in wp-admin has separate first and last name fields. Where are they stored? Can’t I use that for the registration form as well?

    Very confused…


    peterverkooijen
    Participant

    @peterverkooijen

    There are already fields for first_name and last_name in wp_usermeta, so it shouldn’t be necessary to create custom profile fields for them in bp_xprofile.

    How can I add these first_name and last_name fields to the registration form, instead of one “Name” field? And how could the one fullname be generated from first_name and last_name?

    btw, this is standard across a lot of social media sites. Look at Facebook – aside from the fact that they login with email instead of username, they also have display name, first and last….just like BP can have

    Exactly, but how?! Do I really have to get into complicated custom coding to get an “industry standard” registration process?

    Where is that built-in “name & last name” feature that Nicola Greco mentioned?


    lokers
    Participant

    @lokers

    I totally understand you Peter, I am now trying to fix the fact that bp and wpmu have name and surname in two different places in mysql. I just don’t understand it why someone would like to keep it that way? Also, there is a function I found xprofile_sync_wp_profile() which is trying to sync both information, however it doesn’t do it after the registration confirmation and it’s called only after profile update. Currently I am working on big project based on wpmu and bp and many other plugins and opensource code and I must say half of my time I need to fix bugs cos they just don’t work together like they should. Anyway, I shouldn’t complain, at the end of a day it’s free…


    Jeff Sayre
    Participant

    @jeffsayre

    There are already fields for first_name and last_name in wp_usermeta

    Where is that built-in “name & last name” feature that Nicola Greco mentioned?

    The wp_usermeta table actually has four fields, none of which are specifically for first_name or last_name. What you are referring to are data pairs stored between the meta_key and meta_value fields. To extract a first and last name from wp_usermeta, then, requires returning data from two records, not a single record.

    An example:

    umeta_id       user_id       meta_key      meta_value
    22 1 first_name Myfirstname
    23 1 last_name Mylastname


    peterverkooijen
    Participant

    @peterverkooijen

    OK… So what does that mean practically?


    Jeff Sayre
    Participant

    @jeffsayre

    OK… So what does that mean practically?

    Haha! Well, good question.

    WPMU is not designed as a user-centric platform. It is blog-centric. BuddyPress puts the focus on the user.

    So, my best advice is that you will have to do as Mike Pratt suggests and then code a custom function to extract the new firstname and lastname data from an xprofile table as you see fit, or just output that data in your theme files.

    As far as registration, have you looked at Mike’s site (http://buglenotes.com/register) to see what he does? If that is what you want, you should PM him and get more advice.


    peterverkooijen
    Participant

    @peterverkooijen

    So, my best advice is that you will have to do as Mike Pratt suggests and then code a custom function to extract the new firstname and lastname data from an xprofile table as you see fit, or just output that data in your theme files.

    I’m not too worried about displaying firstname and lastname once they are in the database, whereever they end up. My problem is how to customize the registration process to get them there, trying to find the shortest route, avoid redundancies.

    As far as registration, have you looked at Mike’s site (http://buglenotes.com/register) to see what he does? If that is what you want, you should PM him and get more advice.

    That is exactly what I want to avoid! Username is still at the top. I want to eliminate that impersonal username as much as possible. I want a simple, inviting, natural registration form like this:

    • First name
    • Last name
    • Email address
    • Blog name (=username, preferably auto-generated from first+last name)

    That should be enough! Additional optional profile fields would be on a next page or in the members account settings.

    Mike’s site has too many required fields. I assume Display Name is the default full name field in Buddypress and that he just added the others as custom fields.

    This form has username + display name + first name + last name; way too confusing and annoying to potential members. Totally unnecessary, but understandable since Buddypress/WPMU makes it almost impossible to do anything else.


    allenweiss
    Participant

    @allenweiss

    I’m glad to see people talking about this because an additional problem is that if you get people putting in their first and last name (which makes a lot of sense), you won’t find them in the member page based on their last name (which is the way most people would look for another person). Instead you’re forced to find them on their username (which if they use their first and last name for that, you can only find them by their first name).


    Jeff Sayre
    Participant

    @jeffsayre

    That is exactly what I want to avoid! Username is still at the top. I want to eliminate that impersonal username as much as possible.

    I do understand this concept and your desire to achieve this type of setup. However, as I said in my previous post, WPMU is blog-centric, not user-centric. The username field is actually what WPMU stores in the “user_login” field of the wp_users table. Therefore, the way WPMU currently works, this datum is mandatory.

    This particular request is a WPMU issue and has nothing to do with BuddyPress. I’m afraid there is nothing we can do here to help you, but I strongly encourage you to search the WPMU forums for a similar thread and post a new thread if you can’t find anything related.

    At this time, your current options are limited to the ones discussed here.


    peterverkooijen
    Participant

    @peterverkooijen

    This particular request is a WPMU issue and has nothing to do with BuddyPress. I’m afraid there is nothing we can do here to help you, but I strongly encourage you to search the WPMU forums for a similar thread and post a new thread if you can’t find anything related.

    It has everything to do with Buddypress. My question is about the relationship between Buddypress X-Profile tables and how WPMU handles first and last name. It’s about optional fields and how to integrate them into the registration process.

    I do understand this concept and your desire to achieve this type of setup. However, as I said in my previous post, WPMU is blog-centric, not user-centric. The username field is actually what WPMU stores in the “user_login” field of the wp_users table. Therefore, the way WPMU currently works, this datum is mandatory.

    This thread is NOT about the username issue. I use the wp-email-login that allows members to log in with their email address, but I understand the username is still mandatory. That’s why I would like to figure out a way to autogenerate it from first+last name.

    Which brings me back to first and last name. Let me restate the question:

    How does Buddypress handle first name + last name?

    Buddypress puts a default first x-profile field Name on the registration form; is it possible to replace that with separate first name + last name fields? Or should I use Name as First name and create a custom field for Last name?

    Or is there already a native solution for first name + last name in WPMU that Buddypress could tap into? (Nicola Greco: ‘… you could replace it with the wp built-in name & last name, or use xprofile fields fot that …”)

    WPMU is blog-centric, not user-centric.

    Isn’t the whole point of Buddypress to turn the WordPress base into something more user-centric?


    Jeff Sayre
    Participant

    @jeffsayre

    First off, I do sympathize with your frustration on finding an acceptable set of solutions to your questions. Without writing the code for you, it is difficult to point you in the proper direction. There have been a number of options presented, that while being a compromise to your ultimate, desired solution, could produce satisfactory results.

    Isn’t the whole point of Buddypress to turn the WordPress base into something more user-centric?

    Yes and no. As I already said two posts above:

    WPMU is not designed as a user-centric platform. It is blog-centric. BuddyPress puts the focus on the user.

    But, BuddyPress is still a layer that rests on top of WPMU, not the other way around. BP relies heavily on certain WPMU functions to handle much of the user registration process. And WPMU requires that the username field be populated (I realize that you know that).

    This thread is NOT about the username issue.

    I understand that. But what I quoted from your past post was about the username field and that is what I specifically answered in my last post.

    This particular thread is entitled “How to use full name, first name + last name“. Burt already provided an answer to this question above via this thread where he shows you how to do exactly this in code.

    I’ve understood all along in the various threads that you’ve started on this range of related topics that you want another option, some other way to insert your desired datum into the user_login field, or use newly created fields to allow registering users to enter their firstname and lastname, or that you want a way for users to enter their email for login, or a way to use BP’s xprofile table to display fname and lname in various ways and places, or a way to rearrange fields on the registration form, and that you hate WPMU’s concept of username and want a different option. I get all of this.

    Others (including myself) have tried to be as helpful as possible in each of those threads, often rehashing the same answers. I don’t say this to be mean; I say this because we’ve tried to explain in multiple ways and multiple times that what you are after is not possible at this time without hacking the core (in some cases) or writing your own custom plugin(s).

    https://buddypress.org/forums/topic.php?id=1746

    https://buddypress.org/forums/topic.php?id=1811

    https://buddypress.org/forums/topic.php?id=2118

    https://buddypress.org/forums/topic.php?id=2119

    https://buddypress.org/forums/topic.php?id=2926

    How does Buddypress handle first name + last name?

    It does and it doesn’t. There are no firstname and lastname fields in BuddyPress unless you create them as Mike Pratt explained above. BuddyPress has its own mandatory registration field that by default is called “Full Name”. Look in the BuddyPress submenu group in WPMU’s backend. Go to “BuddyPress > General Settings > Full Name field name”

    Now, there is a function in bp-xprofile-filters.php called xprofile_sync_wp_profile() that will take the datum from the “Full Name” field and split it into a pseudo firstname and lastname and then insert that as meta data into the wp_usermeta table, but it can only do that if a user actually edits their fullname field to include a more than one-word name. So if a user does not edit that field, there will not be any fname/lname wp_usermeta entries for that user.

    Buddypress puts a default first x-profile field Name on the registration form; is it possible to replace that with separate first name + last name fields?

    You can change the “Full Name” field name to whatever you want but you cannot remove that field from the registration page nor edit it to be something other than a single textbox field–at least not without hacking the core. Look under the “Basic” field grouping in “BuddyPress > Profile Field Setup” to see what I mean.

    Or is there already a native solution for first name + last name in WPMU that Buddypress could tap into? (Nicola Greco: ‘… you could replace it with the wp built-in name & last name, or use xprofile fields fot that …”)

    In this post above, I explained that if you want to go this route, you’ll need to pull data from two records in wp_usermeta to extract the firstname, lastname combination. If you do not feel comfortable coding this yourself, you could hire a coder to write a simple function to do just that. But be aware, as I explained above, it is possible that not every user will have firstname and lastname meta date.

    From your OP:

    Default Buddypress is fine for teens/tweens who want to use their anonymous username, but it’s not suitable for a more grown-up business network, for example.

    BuddyPress seems perfectly acceptable for business users. There are many professional, adult-based sites that are successfully attracting users to their BP sites. Mike Pratt’s site is a great example, for one.

    I’ve been using my full name on this site from day one. It did not bother me that I had to use a single username when registering because I knew I had the option to fill out my full name for display purposes later. It also allowed me to brand BuddyPress.org with my unique name, creating a useful URI in the process.

    In fact, the single username approach is what many sites use to allow users to brand themselves. Twitter, youtube, FriendFeed, Delicious, Digg, LinkedIn, and many more all require a unique, single-word username. Of course, some of these then allow you to (or even require) that you use an email for subsequent logins. This is in BP’s future as well.

    In the not too distant future, there may be an option to allow users to sign on with their email address via OpenID or another protocol. See the BuddyPress Roadmap and read about the Open Stack.

    But for now, your options are limited and if you want to change things you must code your own custom solution or hack the core.

    There is not much more we can do, but as I said in my last post, if the username concept bothers you so much, you’ll have to go to the WPMU forums and see what solutions might be in the works–if any.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Fact is, that BuddyPress can still only build off of the weaknesses of WordPress itself. What you’re trying to do can really only be worked around with smoke and mirrors, because WordPress itself doesn’t really care what your real name is; the fields exist simply to add depth to a username.

    Short of developing your own MU/BP plugin to shift the emphasis, you’re out of luck. Usernames are 100% necessary, because it’s how you login and out of the site, along with your password. Usernames cannot include characters other than alpha-numeric, so you can’t use an email address either. This means they MUST create a username. You could make a plugin or modify your registration to force the creation of a username based on two fields (first name + last name) but that means you’ll need to tell the user what your website made their login name to be, instead of letting them make their own.

    There really are only a hand-full of sites that don’t use some kind of username as a login, and in my opinion it makes more sense because not everyone uses the same email address for life, and what happens if I registered with my work email address and get laid off, and I need to login but forgot my password? Now my new password goes to an email address I have no access to. In this case, username makes the most sense, and is almost fail safe unless you’re REALLY having a bad day and forgot your username too.

    What about people like me, that like to use their middle names? I get no respect I tell ya! :D


    peterverkooijen
    Participant

    @peterverkooijen

    Now, there is a function in bp-xprofile-filters.php called xprofile_sync_wp_profile() that will take the datum from the “Full Name” field and split it into a pseudo firstname and lastname and then insert that as meta data into the wp_usermeta table, but it can only do that if a user actually edits their fullname field to include a more than one-word name. So if a user does not edit that field, there will not be any fname/lname wp_usermeta entries for that user.

    So this synchronization only happens when users edit their profile after registration? Would it be possible to require the user to enter a more than one-word name in the fullname field and guarantee that synchronization with wp_usermeta always takes place on registration?

    Or would it be easier to use the full name field for first name and add a custom field for last name?

    (Please forget about the username issue. I’ll put that in a separate thread…)


    Jeff Sayre
    Participant

    @jeffsayre

    So this synchronization only happens when users edit their profile after registration? Would it be possible to require the user to enter a more than one-word name in the fullname field and guarantee that synchronization with wp_usermeta always takes place on registration?

    Okay, I made a slight mistake in describing this process. I should not do support after 10 pm.

    If during registration the user actually enters their fullname–which means that there is at least a single space between their first name and whatever comes after that–then this function will parse the datum and create first_name and last_name meta pair entries in wp_usermeta.

    But, if they simply put everything together as a single word, then it will not have anything to parse–it needs a space and something following that space.

    But this is imperfect as jjj has indicated above. Let’s use his name as it appears in BP.org as an example.

    John registers for a BP-based site and enters this in the “Full Name” registration field:

    John James Jacoby

    The function will parse it as follows, placing these entries in wp_usermeta:

    first_name: John
    last_name: James Jacoby

    So, the system does work to some extent but you will have to ask all registering users to make sure they enter just their first name and just their last name with a single space between. If they also include their middle name(s), then those will be assumed to be part of their last name.

    Finally, if they choose to not follow the registration instructions, instead just merge their first, maybe middle, and last names together, then the function will not create the desired first_name and last_name wp_usermeta entries. Those entries will only be created if they latter edit their Full Name profile datum, adding a space between their names.

    So, if jjj instead had entered:

    JohnJamesJacoby

    There would be no entries in wp_usermeta from which you could extract his first and last names.

    You could do a check to make sure that there is at least one single space in the “Full Name” field before allowing the registration to be processed, but you will have no guarantees that they have used their real full name or that they have used just their first and last names.

Viewing 25 replies - 1 through 25 (of 29 total)
  • The topic ‘How to use full name, first name + last name’ is closed to new replies.
Skip to toolbar