I have written a custom module which builds a custom user_profile_form()
:
mymodule_user_profile_form($form, $form_state, $user) {
module_load_include('inc', 'user', 'user.pages');
$form = user_profile_form($form, $form_state, $user, 'account');
// doing stuff with $form ...
return $form;
}
Now, it's working as desired but I noticed a lot of contrib modules are altering the user_profile_form()
calling a hook_form_alter()
on the $form_id == 'user_profile_form'
.
Now, I want all these modifications applied to my custom profile form, too. How to achieve that?
The hacky way would be to go through all modules and change the checks for $form_id == 'user_profile_form' || $form_id == 'mymodule_user_profile_form'
, but this is a no-go and I would appreaciate a clean way to do this. Any idea?
Update: drupal_get_form()
is not the answer as it is not working as desired. This is only returning the $form object without re-building it which causes many issues with theming layer and $form_state['values']
. I'm adding this information as requested by moderator, but this is not part of my question. This is the not working code with drupal_get_form()
b6d1f1d8 and this is the working code with user_profile_form()
d5d43dc0.