I want to programmatically load the user profile form for a particular user and re-submit it without changing any of the existing values. The reasons are complex but I am dependent on gathering data during the form submit phase.

I can see functions to build an empty form ( drupal_get_form ) and to submit a new form ( drupal_form_submit ), but I can't see how to load the form prepopulated with the correct $form_state.


You can try to prepoulate value of any form programmatically & submit like this

$form_state = array(); $form_id = 'invite_form'; $form_state['values']['email'] = 'abc@xyz.com'; drupal_form_submit($form_id, $form_state);

If you want to gather data during user save as mention in question use hook_user_presave.

| improve this answer | |
  • Thanks Rupesh but my requirement is to submit the user profile form with all the existing values in place just as if I'd gone to user/1/edit ( say ) and immediately clicked on submit. – elb Mar 18 '14 at 11:24
  • For profile which module you used ? – Rupesh Mar 18 '14 at 11:29
  • Just Drupal 7's ability to add fields to user objects. – elb Mar 18 '14 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.