function userdata_from_ldap($entry) { if (!isset($entry['lwpfullname'], $entry['lwpmailaddress'])) { return false; } $name = $entry['lwpfullname'][0]; $email = $entry['lwpmailaddress'][0]; $class = strpos($entry['dn'], 'student') !== false ? 'student' : 'staff'; list($firstname, $midname, $lastname) = split_name($name); return array('firstname' => $firstname, 'midname' => $midname, 'lastname' => $lastname, 'email' => $email, 'class' => $class, 'notes' => ''); }
function insert_user($name, $email, $phone, $address) { $password = wp_generate_password(6, false); $name_split = split_name($name); $userdata = array('user_login' => $email, 'user_password' => $password, 'user_email' => $email, 'role' => 'subscriber', 'first_name' => $name_split['firstname'], 'last_name' => $name_split['lastname'], 'user_nicename' => $name); $user_id = wp_insert_user($userdata); if (isset($user_id) && $user_id > 0) { $code = bt_encode_subscrib_code($user_id); add_user_meta($user_id, 'wp_subscrib_active_code', $code); add_user_meta($user_id, 'phone', $phone); add_user_meta($user_id, 'address', $address); $_SESSION['user_id'] = $user_id; update_id_user_to_db(); } }
header("Content-Type: application/json"); echo json_encode($result); } else { $result['exists'] = false; $result['response'] = false; header("Content-Type: application/json"); echo json_encode($result); } die; //WSDL FILE $wsdl = "https://login.workforce.fm/wpfront.asmx?WSDL"; //CREATE CLIENT $client = new SoapClient($wsdl); /* Do Sign Up */ if (isset($_GET['doSignUp'])) { $name = split_name($_GET['contactName']); $parameters = array('firstname' => $name['firstname'], 'lastname' => $name['surname'] ? $name['surname'] : ' ', 'email' => $_GET['emailAddress'], 'password' => $_GET['password'], 'comapanyname' => $_GET['companyName'], 'phoneno' => $_GET['phoneNo'], 'subdomain' => $_GET['subdomain'], 'nooffieldworker' => $_GET['noFieldWorkers']); $value = $client->CreateTrialCompany($parameters); $key = (string) $value->CreateTrialCompanyResult; $result['success'] = strlen($key) ? true : false; $result['key'] = $key; $result['subdomain'] = $_GET['subdomain']; $result['response'] = $value; //before response wait 5 seconds (To allow subdomain to be set up at Amazon because immediate redirect to the account will follow) sleep(5); header("Content-Type: application/json"); echo json_encode($result); exit; } /* Check if Subdomain Exists */ if (isset($_GET['subdomainCheck'])) {