How to trigger hook_form_alter() on my custom $form? 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.
You should use drupal_get_form($form_id) to get the form instead of directly calling user_profile_form() and it will ensure that all the form alters are applied before you get the form.

Update:
          Can you explain why you are not using hook_form_alter()?

But if you want to proceed this way, then instead of calling drupal_get_form() you can replace that with the code from drupal_build_form(), except the call to drupal_process_form(),

Replace drupal_get_form() with the following code, copied from drupal_build-form()

$form_state += form_state_defaults();
if (!isset($form_state['input'])) {
   $form_state['input'] = $form_state['method'] == 'get' ? $_GET : $_POST;
}
$form = drupal_retrieve_form('user_profile_form', $form_state);
drupal_prepare_form('user_profile_form', $form, $form_state);