Discussions

Ask a Question
Back to All

Constructing the custom fields array in php

Greetings, I have a question regarding working with custom fields using the php SDK.

I have a code that successfully creates a user, but it doesn't seem to want to include the custom fields values I have entered, same goes for positions. The user gets created but have the value in these fields empty.

I have skipped the positions for now and do it manually, but is there any other way I should construct the custom fields in the data array? For now I have been trying to use multidimensional arrays but with no luck. Any ideas?

The code I have right now looks like this:

//CODE START
$employee_data_agent = array(
"token" => $token,
"eid" => $_SESSION['id_agent'],
"status" => 1,
"group" => 5,
"email" => $_SESSION['email'],
"birth_day" => $birth_day,
"birth_month" => $birth_month,
"cell_phone" => $_SESSION['phone'],
"address" => $_SESSION['address'],
"city" => $_SESSION['city'],
"state" => $_SESSION['state'],
"gender" => $_SESSION['gender'],
"zip" => $_SESSION['postalcode'],
"password" => $_SESSION['id_agent'],
"username" => $_SESSION['id_agent'],
"send_activation" => 0,
"skills" => $_SESSION['skills'],
"location" => 0,
"custom" => array(
8991 => $_SESSION['level'],
9978 => $_SESSION['country'],
9980 => $_SESSION['safetyName'],
9981 => $_SESSION['safetyPhone'],
9984 => $_SESSION['type'],
9985 => $_SESSION['gender'],
10562 => $_SESSION['socialsecurity'],
10601 => $_SESSION['office'],
10602 => $_SESSION['email']
),
"work_start_date" => $_SESSION['start_date'],
"fname" => $_SESSION['fname'],
"lname" => $_SESSION['lname'],
"name" => $_SESSION['fname']. " " . $_SESSION['lname']
);

$createUser = $shiftplanning->createEmployee($employee_data_agent);

//CODE END

This code gives me success and the user is created, but without the values for custom.

Sincerely,
Adam Åkerman