Cancel user creation from hook_user_presave I created a module that links to Taleo (Talent Management system). When creating a Drupal user, automatically a Taleo Candidate is made.

This works like a charm. But sometimes Taleo answers with an error (example: a candidate with email address info@example.com already exists)

Is there an easy way to cancel the creation of the user from within 'hook_user_presave'? Now the error messages is showed, but the Drupal user is made anyway.

function taleo_user_presave(&amp;$edit, $account, $category) {
    global $client_taleo;
    $session = _taleo_login();
    $error = 0;

    if(!isset($edit['field_taleo_id'][LANGUAGE_NONE][0]['value'])) {
        // NOT LINKED TO TALEO

        $params = array(
            'in0' =&gt; $session,
            'in1' =&gt; array('id' =&gt; '', 'rank' =&gt; '', 'status' =&gt; '0-Available', 
            'firstName'     =&gt; @$edit['field_first_name'][LANGUAGE_NONE][0]['value'], 
            'lastName'      =&gt; @$edit['field_last_name'][LANGUAGE_NONE][0]['value'], 
            'phone'         =&gt; @$edit['field_phone_number'][LANGUAGE_NONE][0]['value'],
            'zipCode'       =&gt; @$edit['field_zip_code'][LANGUAGE_NONE][0]['value'],
            'country'       =&gt; @$edit['field_country'][LANGUAGE_NONE][0]['value'],
            'textResume'    =&gt; @$edit['field_text_resume'][LANGUAGE_NONE][0]['value'],
            'lastUpdated'   =&gt; date('c'),
            'email'             =&gt; @$edit['mail'])
        );

        try{
            $edit['field_taleo_id'][LANGUAGE_NONE][0]['value'] = $client_taleo-&gt;__call('createCandidate', $params);
        } catch (SoapFault $fault) {
            $error = 1;
            $error_message = check_plain("ERROR: " . $fault-&gt;faultcode . "-" . $fault-&gt;faultstring);
            drupal_set_message($error_message);
            watchdog('taleo', $error_message, array(), WATCHDOG_ERROR);
            return array();
        }

    }
The equivalent of hook_user('validate') used in Drupal 6 doesn't exist in Drupal 7. For that, you need to add a form validation handler to user_register_form(), and use form_set_error() when Taleo returns an error.