views:

21

answers:

1

I am trying to create a user in netForum from a Drupal Webform.

Using a webform hook, I am calling two functions to take a users email address and first and last name, and create a netforum account when a user submits basic webforms.

However, the form times out when I hit submit, and the watchdog error from Netforum is 'could not fetch http headers'. Have I done something wrong in my implementation? I keep getting a timeout.

http://wiki.avectra.com/XWeb:WEBWebUserCreate

function inclind_form_webform_submission_insert($node, $submission) {

    // find the email address in the form

    $form_fields = $node->webform['components'];

    foreach ($form_fields as $key => $value) {
        $arguments = array();
        $response = '';

        if ($value['type'] == 'email') {
            $arguments = array(
               'emailToMatch' => $submission->data[$key]['value'][0]
            );

            $response = netforum_xweb_request('WEBWebUserFindUsersByEmail', $arguments, NULL);

            if (!isset($response) || $response->{@attributes}['recordResult'] == 0) {
                inclind_form_create_netforum_user($form_fields, $submission);
            }
        }
    }

    return;
}


/*
*    Create a user in netForum based on form data
*
*     @param $form_fields
*         The form structure passed in from inclind_form_webform_submission_insert
*  @param $submission
*      The form data passed in from inclind_form_webform_submission_insert
*/

function inclind_form_create_netforum_user($form_fields, $submission) {

    $arguments = array();
    $arguments['oWebUser']['Individual'] = array();
    $arguments['oWebUser']['Email'] = array();
    $arguments['oWebUser']['Customer'] = array();
    $arguments['oWebUser']['Business_Address'] = array();
    $arguments['oWebUser']['Business_Phone'] = array();
    $arguments['oWebUser']['Business_Phone_XRef'] = array();
    $arguments['oWebUser']['Business_Fax'] = array();
    $arguments['oWebUser']['Business_Fax_XRef'] = array();


    foreach ($form_fields as $key => $value) {
        if ($value['form_key'] == 'ind_first_name') {
            $arguments['oWebUser']['Individual']['ind_first_name'] = $submission->data[$key]['value'][0];
        }
        if ($value['form_key'] == 'ind_last_name') {
            $arguments['oWebUser']['Individual']['ind_last_name'] = $submission->data[$key]['value'][0];
        }
        if (strlen($arguments['oWebUser']['Individual']['ind_first_name']) && strlen($arguments['oWebUser']['Individual']['ind_last_name'])) {
            $arguments['oWebUser']['Individual']['ind_full_name'] = $arguments['oWebUser']['Individual']['ind_first_name'] . ' ' . $arguments['oWebUser']['Individual']['ind_last_name'];
        }
        if ($value['form_key'] == 'eml_address') {
            $arguments['oWebUser']['Email']['eml_address'] = $submission->data[$key]['value'][0];
            $arguments['oWebUser']['Customer']['cst_web_login'] = $submission->data[$key]['value'][0];
            $arguments['oWebUser']['Customer']['cst_new_password'] = user_password(20);
            $arguments['oWebUser']['Customer']['cst_new_password_confirm'] = $arguments['oWebUser']['Customer']['cst_new_password'];
        }
        if ($value['form_key'] == 'adr_post_code') {
            $arguments['oWebUser']['Business_Address']['adr_post_code'] = $submission->data[$key]['value'][0];
        }
    }

    if (!isset($arguments['oWebUser']['Business_Address']['adr_city'])) {
        $arguments['oWebUser']['Business_Address']['adr_city'] = 'Not Given';
    }

    if (!isset($arguments['oWebUser']['Business_Address']['adr_state'])) {
        $arguments['oWebUser']['Business_Address']['adr_state'] = 'NA';
    }

    if (!isset($arguments['oWebUser']['Business_Address']['adr_post_code'])) {
        $arguments['oWebUser']['Business_Address']['adr_post_code'] = '00000';
    }

    if (!isset($arguments['oWebUser']['Business_Address']['adr_country'])) {
        $arguments['oWebUser']['Business_Address']['adr_country'] = 'Not Given';
    }

    if (!isset($arguments['oWebUser']['Business_Phone']['phn_number'])) {
        $arguments['oWebUser']['Business_Phone']['phn_number'] = '000-000-0000';
    }

    if (!isset($arguments['oWebUser']['Business_Phone_XRef']['cph_extension'])) {
        $arguments['oWebUser']['Business_Phone_XRef']['cph_extension'] = '000';
    }

    if (!isset($arguments['oWebUser']['Business_Fax']['fax_number'])) {
        $arguments['oWebUser']['Business_Fax']['fax_number'] = '000-000-0000';
    }

    $response = netforum_xweb_request('WEBWebUserCreate', $arguments, '1 min');
    watchdog('netforum', 'netforum user @user created', array('@user' => $arguments['oWebUser']['Email']['eml_address']), WATCHDOG_NOTICE);
}
A: 

Solved: http://drupal.org/node/866534

Kevin
Wait a couple days and select your own answer.
Will