Adding custom usermeta to Registration
-
I have tried following this tutorial – http://buddypress.org/forums/topic/how-to-add-custom-usermeta-to-registration – but have not been able to get this working properly.
I have racked my brain to be able to do this without editing core files. I have easily been able to add the form fields and include it in the $_POST but it just won’t save to $wpdb->usermeta!
I have been testing by hardcoding update_usermeta() functions in the over-arching bp_core_signup_user() but I can’t figure out how to hook into the bp_core_signup_user() or override it.
Does anyone know how to add these usermeta records on signup, or has gotten the tutorial above to work?
Does anyone know how to add functions to the bp_core_signup_user() function, or register usermeta’s in the signup form?
I’ve been racking my brain with this one, it would be great to get some help!
-
I use a function with something like this:
function example_wp_usermeta($user_id, $password, $meta) {
global $bp, $wpdb;
$uid = get_userdata($user_id);
$email = $uid->user_email;
$fullname = $meta[field_1];
...
update_usermeta( $user_id, 'nickname', $fullname );
...
}
add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);I’m not sure that I follow this. I can’t find this action “wpmu_activate_user” . Are you referring to “wpmu_activate_signup?”
As far as I know wpmu_activate_user is a plugin action hook. Also mentioned here. It works for my function. Not sure what you need exactly.
I too have also tried to use the tutorial that carrotcreative has mentioned, but not managed to get it working. The reason for my problem though I believe is that I am trying to use BuddyPress 1.2.1 on a standalone installation of WordPress 2.9.2. The tutorial is referencing the hook “bp_core_activate_account” which as far as I can see is in turn calling the function “wpmu_activate_signup” which I am guessing doesn’t exist outside of MU.
I’ve tried using the “user_register” too hook onto and run the “update_usermeta” ,but that doesn’t appear to be working. Does anyone know what hook should be used for standalone WordPress in the absence of “bp_core_activate_account”
Thanks.
I think that I may have come up with a solution for my issue with custom signup fields using BuddyPress 1.2.1 on a standalone installation of WordPress 2.9.2. After much digging around I basically ended up with a function that looks a little like the one below in my bp-custom.php file.
function bp_custom_signup_fields( $user_id) {
$bpCustomField = $_POST['bp_custom_field'];
update_usermeta( $user_id, 'bp_custom_field', $bpCustomField );
return $user_id;
}
add_action( 'user_register', 'bp_custom_signup_fields' );This seems to be working as I want it to, but if anyone is aware of any issues that this may cause, please do let me know.
Thanks, many people will need this. I’ll check it out.
Is user_register the same point in the process as wpmu_activate_user?
I’m still on BP 1.1.3, still have to upgrade to 1.2…
I’m not sure I get it, chip-d. So in my registration form do I need to put something like:
< code ><label for=”signup_username”>CUSTOM</label>
<input type=”text” name=”bp_custom_field” id=”bp_custom_field” value=”” /></ code >
I tested this out, it does indeed work.
- The topic ‘Adding custom usermeta to Registration’ is closed to new replies.