How to run xprofile_sync_wp_profile() on registration

Can anyone please tell me how to run xprofile_sync_wp_profile() on registration?

xprofile_sync_wp_profile() splits first_name and last_name from BP’s fullname registration field and stores them in WordPress’ standard usermeta table. That is tremendously useful, if you can count on that data being there.

I’ve tried putting the function in a plugin to run on user_register as action hook, but got a “cannot redeclare” error because the function is already in bp-xprofile-filters.php.

I’ve tried editing the add_action thingy in that file from xprofile_updated_profile to user_register, but it had no effect.

I can’t find any more documentation on how to use this function.

Any pointers very much appreciated!

Edit: As far as I understand this function now only kicks in when the user updates his profile:

add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );

That could be never, so you can never count on that first_name, last_name data being there in wp_usermeta. In my case I need first_name, last_name “somewhere” for synchronisation with ListMessenger mailing list. There are many other scenarios where you’d need them.

Replacing xprofile_updated_profile with user_register did not work. Should I try other hooks? Which ones? Or am I on the wrong track? Does the ‘$bp->loggedin_user->id’ line make it impossible to run this function on registration? How about on first login? Is there a hook for that?

I guess function xprofile_sync_wp_profile() requires that the fullname (BP_XPROFILE_FULLNAME_FIELD_NAME) is already in the database and that the function can only be run after the user is already logged in.

So I guess I need to write another function that takes the fullname straight from the registration form and can be run with the user_register hook.

Where can I find the functions that take the data from the registration form and store them? I could probably use them as examples to come up with my own fuction for a plugin.

Edit: I guess all the magic happens in bp-xprofile-signup.php (function xprofile_load_signup_meta())? Is there a way to add a x-profile/wp_usermeta synchronization function to that file?

Hi
I have the latest Wp and latest BuddyPress 1.9.2
On the new user registration form it has FULL NAME box
But I need FIRST NAME and LAST NAME boxes. So I can in admin panel and users on frontend can register new users can fill their names with 2 boxes. And on search page users can search other users by first name or last name. And I can hide last names for some users etc.. Its always convenient to have first and last names in separate DB columns. So please help me out, how can I have the BuddyPress plugged site of mine to function like above?
Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to run xprofile_sync_wp_profile() on registration’ is closed to new replies.