$_POST); drupal_form_submit($_POST['form_id'], $form_state); // $return['form_state'] = $form_state; $return['errors'] = form_get_errors(); if($return['errors']){ unset ($_SESSION['messages']['error']); }else{ $messages = drupal_get_messages('status'); // $return['messages'] = $messages; drupal_set_message(t("Congratulations, you juste created your free materiO' account, welcome !"), 'status'); foreach ($messages['status'] as $msg) { drupal_set_message($msg, 'status'); } } // after registration user is automaticly logged in, thank's to login tobogan module drupal_json_output($return); } function materio_user_login_submit(){ $return = array(); $return['POST'] = $_POST; $form_state = array("values"=>$_POST); drupal_form_submit($_POST['form_id'], $form_state); $return['errors'] = form_get_errors(); if($return['errors']) unset ($_SESSION['messages']['error']); // if user-login form succed we retreive the user uid on $form_state, then we can effectively loggin the user if($uid = $form_state['uid']) user_login_submit(array(), $form_state); drupal_json_output($return); }