How to merge two forms (with separate purposes) and have one submit? Problem

I'm trying to combine two forms. A custom form and the user register form. I want the user to be able to fill in both and submit them together. How would I do this?

CONTEXT: The custom form creates a node, but you have to be logged in to do it. To lower the barrier I want users to be able to create the node and register on the same screen.

(Ideally the user register form won't appear if they're logged in.)

So Far

I tried calling two forms on the page but they have different submit buttons.

function postajob_page_callback() {
    $build = array();

    $build['form_one'] = drupal_get_form('postajob_form');
    $build['form_two'] = drupal_get_form('user_register_form');
  return $build;
}


So I called the user register validate and submit handlers in the custom form validate and submit calls.

function postajob_form_validate($form, &amp;$form_state) {
     user_register_validate($form, $form_state);
     ...
 }

function postajob_form_submitform, &amp;$form_state) {
     user_register_submit($form, $form_state);
     ...
 }


This calls the function but because the form doesn't contain any of the fields (i.e. username, email, password etc.) it  throws a horrible error:

Notice: Undefined index: administer_users in user_register_submit() (line 3824 of C:\XAMPP\htdocs\drupal5\modules\user\user.module).
Notice: Undefined index: pass in user_register_submit() (line 3827 of C:\XAMPP\htdocs\drupal5\modules\user\user.module).
Notice: Undefined index: mail in user_register_submit() (line 3838 of C:\XAMPP\htdocs\drupal5\modules\user\user.module).
Notice: Undefined index: #user in user_register_submit() (line 3840 of C:\XAMPP\htdocs\drupal5\modules\user\user.module).
Warning: Creating default object from empty value in entity_form_submit_build_entity() (line 8009 of C:\XAMPP\htdocs\drupal5\includes\common.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name': INSERT INTO {users} (uid, created, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] =&gt; 165 [:db_insert_placeholder_1] =&gt; 1379868880 [:db_insert_placeholder_2] =&gt; a:6:{s:16:"ckeditor_default";s:1:"t";s:20:"ckeditor_show_toggle";s:1:"t";s:14:"ckeditor_width";s:4:"100%";s:13:"ckeditor_lang";s:2:"en";s:18:"ckeditor_auto_lang";s:1:"t";s:17:"mimemail_textonly";i:0;} ) in drupal_write_record() (line 7166 of C:\XAMPP\htdocs\drupal5\includes\common.inc).


So I tried to merge the forms using info from here and I added the following two lines of code just before the submit button in the form.

function postajob_form($form, &amp;$form_state) {
      ....

     $extra = user_register_form($form, $form_state);
     $form = array_merge($form, $extra); 

     $form['submit'] = array(
       '#type' =&gt; 'submit',
       '#value' =&gt; t('Submit'),
      );

    return $form;
}


This adds the form but seems to break the submit button and both submit buttons call the user_register submit not the custom form submit. Any ideas?
Instead of using custom form you can add fields.
Go to
Administration » Configuration » People » Account settings

And In the manage fields tab u can add  fields you want. 

You can check the commerce_auto_product_display module tar files which has used similar functionality of adding nodes to the already built form