There isn’t anything special about the “Name” field aside from it being required. You could treat the field as the member’s first name and set up a second field labelled “Surname”?
Thanks for the reply, so you’re saying I should rename this field to “First Name” and create a secondary field for “Last Name” ? If there is nothing special about the field, is there a hook or filter where I can replace the field entirely and map them to first / last name fields in WordPress?
Thanks for the reply, so you’re saying I should rename this field to “First Name” and create a secondary field for “Last Name” ?
That’s one approach you could take.
If there is nothing special about the field, is there a hook or filter where I can replace the field entirely and map them to first / last name fields in WordPress?
I think not unfortunately. You could request one be added by opening a ticket on Trac
I was dealing with this problem too. It might not be exactly what you’re looking for, but in my case I just decided to hook into the BP signup, extract the full name, split it at the first space and then update the WordPress ‘first_name’ and ‘last_name’ user metadata fields with the results.
Here is the code you can add to your functions.php
or custom plug-in:
// define the bp_core_signup_user callback
function ac_bp_core_signup_user( $user_id ) {
// make action magic happen here...
$fullname = bp_get_member_profile_data( array( 'field' => 'Name', 'user_id' => $user_id ) );
//split the full name at the first space
$name_parts = explode(" ", $fullname, 2);
//set the firstname and lastname for WordPress based on the BP name
//firstname
if( isset($name_parts[0]) )
update_user_meta( $user_id, 'first_name', $name_parts[0] );
//lastname
if( isset($name_parts[1]) )
update_user_meta( $user_id, 'last_name', $name_parts[1] );
//not needed for an action, but I always like to return something
return $fullname;
}
// BuddyPress save first name last name to WP profile on signup
add_action( 'bp_core_signup_user', 'ac_bp_core_signup_user', 10, 1 );
That’s a good idea! The problem I forsee with that is they may not enter a last name and I’m trying to run the social part of the site with a first name / last name basis as I’ve seen in communities there’s less trolling and more politeness whenever your first / last name is out there.
Of course this doesn’t stop people from enter faux content but it’s a start. Connecting with Facebook / Google also helps. This is just a piece of the puzzle which it turns out unfortunately must be rotated. I did bookmark it for the hook though, that’ll come in handy!
The problem with bp_core_signup_user is it’s executed during registration only. If a member decides to change their “Name” at a later date, I don’t think the corresponding WordPress fields will be updated.
Good point @henrywright. In our case it may not matter too much since for us this is only so we see a name in the admin interface. On the front end we are only using the xprofile name. Still is there possibly another hook that I could tie into that runs on user profile update?
There sure is: xprofile_field_after_save
Let me know if you need anything else.