I have an idea but not sure will it work:Any suggestions? thx!
- Implement
hook_field_attach_form
to attach the field to event registration form and load value from Profile entity. - Implement
hook_field_attach_submit
to update/save data to Profile entity.
I would use theEDIT: I implemented this functionality. For those interested, complete source code is below to update user field: (Note that I'm saving data to profile2!)
/**
*
* Implements hook_form_alter
*
*/
function loadMYMODULE_form_alter(&$form, user&$form_state, object$form_id) {
$existingUser global $user;
if ($form_id == 'registration_form') {
$profile = user_loadprofile2_load_by_user('USERID'$user->uid);
// createLoad anprofile2 arraydata
of properties to update if ($profile['main']->field_linkedin_url) {
$edit $linkedin_url = $profile['main']->field_linkedin_url['und'][0]['value'];
}
$form['linkedin_url'] = array( // Add field to form
'profile_linkedIn url' '#type' => 'blah''textfield',
'#title' => t('Your LinkedIn profile');,
'#default_value' => isset($linkedin_url) ? $linkedin_url : '',
'#maxlength' => 255,
'#size' => 60,
'#description' => t('Please enter your LinkedIn profile URL'),
'#weight' => 10,
);
$form['#submit'][] = 'entity_registration_custom_registration_form_submit'; // saveCall existingcustom usersubmit handler
user_save(
}
}
/**
*
* Custom Form Submit Handler
*
*/
function MYMODULE_MYFORM_submit(object$form, &$form_state){
array('uid' => $existingUser global $user;
$profile = profile2_load_by_user($user->uid),
; // $edit,Load profile2 data
'Personal Information' $profile['main']->field_linkedin_url['und'][0]['value'] = $form_state['values']['linkedin_url']; // categorySet new value for Profile2 field
profile2_save($profile['main']);
drupal_set_message(t('Submit handler works!'));
}
Any suggestions? thx!