wp and bp profile syncing–works only sporadically
-
I’m running mu2.8.6/bp1.1.3, and the problem I’m having is that most of the time, when my students register on the site and complete the BP profile, that information is not synced with the WP profile. The BP profile will show the full name, but when I go to the WP profile on the backend, I see only the username and nickname fields are populated, and the others are blank; the display name shows the username.
So, when that student comments on a post, her username is shown, and there’s no link back to her profile. However, a few students register (for instance, one did just a few minutes ago) and all their information is fully synced–the WP profile shows username, first name, last name, the display name shows first and last, and the URL is the BP profile.
I have not been able to determine what, if anything, these few exceptions do differently to have their profiles sync. I’m assuming that these exceptions are what is supposed to be the rule when profile syncing is working correctly.
Any ideas on what I can do to get this working correctly all the time?
-
This is my big pet peeve with Buddypress; there is no consistent built-in way to store fullname (as firstname + lastname). Profile synching only happens when members update their profile using the WP backend.
This is by design. BP’s lead developer Andy Peatling believes firstname/lastname would not work for international users.
My ugly workaround is here. Also see this one. I use the Javascript trick to generate a username from the fullname, so at least those are easier to recognize.
@Peterverkooijen, thanks for the the links and explanation. I tried your “ugly workaround,” putting it into a plugin, but I get this error:
Fatal error: Cannot redeclare synchro_wp_usermeta() (previously declared in /home/dandoese/public_html/wp-content/plugins/bp-custom.php:15) in /home/dandoese/public_html/wp-content/plugins/bp-custom.php on line 35
(In other words, the beginning of the function and the end); undoubtedly I have missed something somewhere in how I’m supposed to use this code.
Looks like the function is already in your bp-custom.php, which is not part of standard Buddypress. Can you check in the file if it’s the exact same code?
If so, how did it get there…?
If it’s not the same function, you can probably fix the problem by search/replace in the function: synchro_wp_usermeta -> custom_synchro_wp_usermeta
I don’t remember if I replaced an existing function with the same name. Buddypress did have a function to update wp_usermeta when profile info is updated, but I think that one had another name.
I created bp-custom.php, and it contains only your code. I just added a plugin heading above it and wrapped it in an opening and closing php tags.
I don’t know if I necessarily need to generate new data but I’d like to have teh BP name show instead of the username on blog comments. Probably as simple as replacing the call that shows the username in comments with a query feeding in the username and returning the first and last name, if only for display purposes
@Dan https://wordpress.org/extend/plugins/buddypress-real-names/installation/ but I have no idea if it does anything special with BP->WP profile syncing. If you’ve got a repeatable case of BP changes not syncing to the WP profile, please create a bug ticket on https://trac.buddypress.org/.
What does that plugin do? It has some vague requirements:
Create three news fields that will be used by the plugins (ex. “Member name”, “Member firstname”,”Member bothnames”). I suggest “Member name” to be a required field.
Fill the values of those fields for your profile (the datas for at least one user are needed to setup the plugin options)
Where are you supposed to create those fields? xprofile? In addition to the existing fullname field? You can already do that without this plugin.
wp_usermeta is nowhere in the plugin. That is the table WP uses to store firstname and lastname. Any solution in Buddypress should leverage wp_usermeta or at least synchronize with it imho. This plugin solves nothing.
If you’ve got a repeatable case of BP changes not syncing to the WP profile, please create a bug ticket on https://trac.buddypress.org/.
The problem Dan Butcher described looks like standard Buddypress behavior to me. It’s not a bug, it’s a feature, based in Andy Peatling’s design decision that firstname + lastname would cause international incidents.
Below again my hack as I use it in my sites, minus creation + update of a fullname-derived username for user_login, user_nicename, user_url and integration with a mailing list script I use:
function synchro_wp_usermeta($user_id, $password, $meta) {
global $bp, $wpdb;
$uid = get_userdata($user_id);
$email = $uid->user_email;
$fullname = $meta[field_1];
$space = strpos( $fullname, ' ' );
if ( false === $space ) {
$firstname = $fullname;
$lastname = '';
} else {
$firstname = substr( $fullname, 0, $space );
$lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
}
update_usermeta( $user_id, 'nickname', $fullname );
update_usermeta( $user_id, 'first_name', $firstname );
update_usermeta( $user_id, 'last_name', $lastname );
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
}
add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);I have this code in bp-custom.php or functions.php, not as a plugin. Adding a plugin header could have caused Dan Butcher’s error messages.
BTW, I’m still looking for code to validate the fullname input for at least a two part name, so make a space required. I now get a lot of users only entering a first name. In that case the lastname field in wp_usermeta will stay empty.
Why not do the following (as we have)
1. Have 4 name fields in BP registration
1. username
2. 1st name
3. last name
4. display name (the bp required field)
Make them all required. We describe “display name” to everyone as “how you want your name to be viewed throughout the site’ If we had a choice, we’d get rid of it and mash 1st and last names together for display purpose. On the other hand, we have also seen many users do the following:
1. username -> jim1974
2. James
3. Smith
4. Jim Smith
Obviously, this allows for nicknames and with a little prodding, you get people entering nicer monikers than “ladiesman269”
Now, with the (lame) fact that WP user table is actually different (not sure why it wasn’t co-opted for BP purposes) All you have to do is create a function that writes the xprofile field values for 1st and Last name over to the WP table, in addition to setting the “display name value accordingly.
a thousand user later and no one has complained.
Why not do the following (as we have) …
1. username
2. 1st name
3. last name
4. display name (the bp required field)
Because it’s not necessary. The goal should be to keep the registration form as short and simple as possible and not annoy new users.
Look at the registration process on Facebook, LinkedIn, etc. Most have:
First Name:
Last Name:
Email:
Password:
I use a javascript trick generate the username from the fullname in a hidden field – I can use email as username thanks to this plugin. Since BP has a built-in fullname field I’m stuck with splitting that out in firstname and lastname.
I have considered using fullname for firstname and creating a field_2 for lastname, but that causes all kinds of other issues.
Unfortunately there is no check/validation on what’s entered in the fullname field. The input is also not cleaned up to get capitals on the first letters and small caps on the rest. So the input could be anything, often just a first name or even ladiesman269.
Which undermines any reason of having that required fullname/display field in the first place…
All you have to do is create a function that writes the xprofile field values for 1st and Last name over to the WP table, in addition to setting the “display name value accordingly.
You have to do that straight from the registration form, to make sure that the data is there where/when you need it. That is basically what my function does. If you can get it to work. Apparently it doesn’t for Dan Butcher.
Now, with the (lame) fact that WP user table is actually different (not sure why it wasn’t co-opted for BP purposes)
That had mystified me since last Spring, but here’s Andy’s reason.
As much as I agree that you want to keep it simple, the last thing I want to do is a. auto-generate usernames (you have to tell them and they have to remember – let them decide) or b. parse a field into various name fields (parsing is just begging for errors – too may what-ifs)
FYI – Facebook has you do the same 4 fields you mention you are doing. Fine. But look deeper: they then auto-generate a username. why? who knows since you always login with an email address. Additionally they auto-gen a drop down list of “display names”
So what’s the diff between me and FB? I let you pick your display name up front in addition to your username. Ideal no but better than the alternative…for me.
Bottom line is: let’s keep this discussion to how to do our own work arounds. The core way of doing does not appear to be changing. Fine (we can always leave the BP-sphere) Instead, let’s make it work.
I hearby declare it off limits to refer to Andy’s decision not to include firsname/lastname ever again. We get it.
As much as I agree that you want to keep it simple, the last thing I want to do is a. auto-generate usernames (you have to tell them and they have to remember – let them decide)
They don’t in my site. They log in with email address. The only reason to still have an (autogenerated) username is because you need it for the URL.
parse a field into various name fields (parsing is just begging for errors – too may what-ifs) … But look deeper: they then auto-generate a username. why? who knows … Additionally they auto-gen a drop down list of “display names” … So what’s the diff between me and FB?
Also not much difference between me and FB. The difference between your solution and FB is what the user actually sees on the registration form. I don’t believe a new user will be all that interested in those extra choices.
I hearby declare it off limits to refer to Andy’s decision not to include firsname/lastname ever again.
It’s not up to you to decide what the limits of discussion are. You may get it, but until Andy/WP/Automattic gets it I’ll keep bringing it up. I like the features WP/WPMU/BP offers, there are really no alternatives for those, but they need to get central member management and the database structure up to standard.
I don’t understand your issues with member management? WordPress MU provides excellent member management tools, and BuddyPress rides on the back of this. What is it that you need so desperately?
Dude – it was sarcasm. Or a more polite way of saying “We get your point. You don’t like the way he does names. Ok. No need to hammer it home on every single thread, every chance you get.” Just trying to help so you’re not completely ignored.
@Andy I think the central issue is that WP and BP store member info separately. For the uninitiated, it means that comments on blogs on a BP sire will not show the same profile info as comments on forums, etc. b/c the blog gets it’s info from the Wp table. So if you go into my admin on my site, none of the info is filled out except email and username, altho there’s AIM, website, First Name etc. But none of that is made avail into a BP install. On my site, the blog comments say ” username” commented….. instead of “Display name” commented.
Additionally, if WP has all those user fields, why are they not exposed to BP already? That’s what is being talked about. So I am writing functions to sync up that data.
I don’t understand your issues with member management? WordPress MU provides excellent member management tools, and BuddyPress rides on the back of this. What is it that you need so desperately?
What is your solution to the main question of this thread? I have given my hack, but it doesn’t work for Dan Butcher.
Also if the member management tools are so great, can you answer how to display basic profile information anywhere in the theme?
My main issue with member management in BP is that there is no built-in consistent way to store firstname+lastname, as I’ve explained over and over to the annoyance of many on this forum. It makes it much more difficult to integrate third party scripts that do require firstname + lastname, like mailing list ListMessenger in my case.
Commercial membership plugins apparently create their own members table to not be stuck in WP’s built-in users management. If WP had a more solid solution that would not be necessary.
WordPress provides a decent base, but over the years bits and pieces were apparently added in different tables – nickname, display name, first name, last name, … – and BP added xprofile on top of that without synchronization with wp_usermeta. But I’m repeating myself again…
Just trying to help so you’re not completely ignored.
I’m ignored anyway.
What is your solution to the main question of this thread? I have given my hack, but it doesn’t work for Dan Butcher.
Point me to a ticket with steps to reproduce and I will happily take a look at it.
Also if the member management tools are so great, can you answer how to display basic profile information anywhere in the theme?
This is all over the forums, but I’ll post it again:
<?php echo xprofile_get_field_data( $field_id_or_name, [ $user_id optional ] ) ?>
My main issue with member management in BP is that there is no built-in consistent way to store firstname+lastname, as I’ve explained over and over to the annoyance of many on this forum.
This isn’t going to change, I’m not going to force people to enter “firstname” and “lastname” for the same reasons I wouldn’t force people to enter “state” or “postal code”. You can bring it up as much as you’d like on the forums, but a solution that works for everyone in the world is to have a single field. If you would like something else, then it’s possible to write a plugin or work around it. I’ve seen no more than ten people complain about this out of everyone who uses BuddyPress. If this was a widespread issue then there would be endless complaints and tickets.
@Andy I think the central issue is that WP and BP store member info separately. For the uninitiated, it means that comments on blogs on a BP sire will not show the same profile info as comments on forums, etc. b/c the blog gets it’s info from the Wp table. So if you go into my admin on my site, none of the info is filled out except email and username, altho there’s AIM, website, First Name etc. But none of that is made avail into a BP install. On my site, the blog comments say ” username” commented….. instead of “Display name” commented.
This will be somewhat addressed in 1.2.
The post your referring to Peter is about displaying profile information in a user blog not in the themes..
While I do agree with your points (I would like this to be easier as well) it probably the way you’re saying it that’s putting people off. You seem to have a tendency to approach people in a very direct and confronting way. I certainly don’t feel the need to help you out (if I could, which mostly I can’t) if you remain to have an certain tone in your posts which seem to be very negative and overly critical. As a journalist you must know how important it is to package your message the right way, and your approach does not work very well in my opinion since you seem to be involved in all kinds of small conflicts.
Now I’ve seen you help others quite a few times in a very polite manner, so if you could try to have the same attitude towards others as the ones you’re helping, than I bet that your suggestions (which are not crazy or “bad”) could get picked up and worked upon. There’s no need to keep on raving about a certain topic if the core developer already aware of the situation and is currently working on 1.2, which we all want to see to badly.
Just my 2 cents sorry for going offtopic
I’ve seen no more than ten people complain about this out of everyone who uses BuddyPress. If this was a widespread issue then there would be endless complaints and tickets.I’ve seen no more than ten people complain about this out of everyone who uses BuddyPress. If this was a widespread issue then there would be endless complaints and tickets.
You will see more complaints when Buddypress moves out of the current audience of typical wp-users/coders/bloggers to businesses, schools, associations, etc.
You seem to have a tendency to approach people in a very direct and confronting way.
I’m not trying to make friends and don’t expect a lot of help anyway. I use the forums partly to keep track of my own development issues and partly to let the developers know where the real pain points are for a regular user, who knows some html/css and a bit of php, but is not a programmer.
I also represent the people who are not on this forum; who try BP, get frustrated and give up.
But yes, this is all off-topic. The question is still wp-bp profile syncing!
Then I give up.. If you are not trying to make friends or be nice in a community which is based on collaboration and free support then I think you will have a very hard time getting help and response for your problems. Even if your problems get adressed, responded and possibly even fixed (which Andy just did) you’re actually not even thanking him. Unbelievable.. I’ll now stop with posting here before DJ Paul discovers this thread.. lol
@Andy cool. I should have highlighted the fact that blog posts and comments in 1.2 bring in BP xProfile field data quite nicely which tackles the crux of the problem.
I AM interested in your thoughts on the two sep data structures for user info and how we should approach that.
@Peter Good Luck to ya, pal. I would remind you of the “more flies with honey than vinegar” saying but you’re not here to catch flies then are you?
@Mike: you are saying that from BP 1.2 you can display user info (xprofile fields) into member blogs? So you could create a widget on a blog which would display basic info from the author (BP avatar + xprofile fields_
That would be great, but I’m not sure if that was what you meant to say!
You can do this since the beginning of BP 1.0, Bowe!
Seriously? Some smart guy told me otherwise.. don’t know who it was but DAMN.. thanks! Could you tell us how? And maybe tell the other poor souls who want to know as well in this topic:
https://buddypress.org/forums/topic/display-xprofile-field-in-blog-post
Maybe it’s better to reply there since it’s semi offtopic.
After some consideration, any further posts by anyone below this point which are not in scope of Dan’s post, or are construed as being impolite and confrontational, will be deleted.
- The topic ‘wp and bp profile syncing–works only sporadically’ is closed to new replies.