diff --git a/inline_registration.module b/inline_registration.module index e0ed448..922062a 100644 --- a/inline_registration.module +++ b/inline_registration.module @@ -39,10 +39,13 @@ function inline_registration_form_alter(&$form, &$form_state, $form_id) { // Add our own validation and submit function to the node_form $form['#validate'][] = 'inline_registration_validate'; - $form['#submit'][] = 'inline_registration_submit'; - - // And ensure our submit function is called first (so the node is authored by the newly created user) - $form['#submit'] = array_reverse($form['#submit']); + if (is_array($form['#submit'])) { + // And ensure our submit function is called first (so the node is authored by the newly created user) + array_unshift($form['#submit'], 'inline_registration_submit'); + } + else { + $form['#submit'] = array('inline_registration_submit'); + } } @@ -77,7 +80,14 @@ function inline_registration_form_alter(&$form, &$form_state, $form_id) { * Validation routine for inline registration form. */ function inline_registration_validate($form, &$form_state) { - $form_state['values']['name'] = $form_state['input']['name']; // for some reason the name is empty and a scrypt works incorrectly so copy it from other variable + + // if we integrated with email_registration, name won't be there + if (module_exists('email_registration') && !isset($form_state['input']['name'])) { + $form_state['values']['name'] = $form_state['input']['mail']; + } + else { + $form_state['values']['name'] = $form_state['input']['name']; // for some reason the name is empty and a script works incorrectly so copy it from other variable + } unset($form_state['uid']); if (module_exists('logintoboggan')) {