I am working on custom app for a client that requires some extra fields in the user's profile. I have successfully created a registration page that saves the custom fields and now I need to do the same for the "Edit Profile" page. The function that I used to save the custom fields on registration is generic enough that I think I can use it for the update too. I cannot find the right hook to make it work, though. I have tried "profile_update", "edit_user_profile_update", and "personal_options_update" with no luck. Is there something that I am missing here?
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Nicolai, kaiser
After trudging through the BP source code today, I believe that I have finally figured this out. The hook used to update Profile Fields in BuddyPress is "xprofile_data_before_save". If anyone know of something better, please let me know!
You could also use the extended profiles function include in buddypress to create extra profile groups / fields.
Then you can all the groups into the register or edit page by just replacing the loop
<?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
<?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile() ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
With that you will display all profile groups in the register page. You can do the same with edit.php to display all fields in the edit profile page.
To make this work properly you know need to do a small tweak. You need to move the out of the loop and then save all the fields ids like this:
You also move this outside of the loop so it will look:
<?php endwhile; endif; endif; ?> <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php echo implode(",",$fields_ids);?>" /> </form>
The last part is to be sure that all fields are saved into the database. Hope it helps, i used on edit.php but it should work the same on register.php