Getting " You have not completed all the user fields" error while creating user using PHP API


(Amandeep Singh) #1

Hi Team,

i am trying to create user with details like : name=JohnDoe123&username=JohnDoe123&email=johndoe%40discoursehosting.com&password=1234567898&active=true. This always return error like stdClass Object ( [http_code] => 200 [apiresult] => stdClass Object ( [success] => [message] => You have not completed all the user fields ) ).

So please update me what i am doing wrong and which value not i am not passing while create a user.

This is very urgent for me.


(Vinoth Kannan) #2

can you share your php API code too?


(Amandeep Singh) #3

Please check below code Code:-

    require_once "lib/DiscourseAPI.php";

    $api = new DiscourseAPI("experts.example.com", 'dummykey', 'https');

    // create user//
    $r = $api->createUser('JohnDoe123', 'JohnDoe123', 'johndoe@gmail.com', '1234567898');
    print_r($r);

    function createUser($name, $userName, $emailAddress, $password)
    {
    $obj = $this->_getRequest('/users/hp.json');

    if ($obj->http_code != 200) {
       return false;
    }

    //print_r($obj);

    $params = array(
        'name' => $name,
        'username' => $userName,
        'email' => $emailAddress,
        'password' => $password,
        'active'=>'true'
    );


    return $this->_postRequest('/users', $params);


    }

(Vinoth Kannan) #4

You should not post your API key in public. Please change your API key in your admin console.


(Amandeep Singh) #5

Ok. Please update me what i am doing wrong in code.


(Amandeep Singh) #6

I also try to submit these field like this:

 $params = array(
            'name' => $name,
            'username' => $userName,
            'email' => $emailAddress,
            'password' => $password,
            'active'=>'true',
            'challenge' => strrev($obj->apiresult->challenge),
            'password_confirmation' => $obj->apiresult->value
        );

But get same error.


(Vinoth Kannan) #7

Did you setup any required custom fields in admin console?


(Amandeep Singh) #8

How i can check custom field setting field in admin console


(Vinoth Kannan) #9

You can see it in /admin/customize/user_fields


(Amandeep Singh) #10

Yes. 3 custom field are set but one is required.


(Amandeep Singh) #11

I have pass the fields like:

$params = array(
            'name' => $name,
            'username' => $userName,
            'email' => $emailAddress,
            'password' => $password,
            'active'=>'true',
            'Community Type'=>'Other',
            'Facebook'=>'asd',
            'Twitter'=>'asd',
            'challenge' => strrev($obj->apiresult->challenge),
            'password_confirmation' => $obj->apiresult->value
        );

But still same error.


(cpradio) #12

Go to your site, press F12 to open Dev Tools, Create an Account, go to the Network Tab to see what fields were posted to create the account, make sure you add any of those fields custom fields to your array.


(Amandeep Singh) #13

What do you mean by account create?


(cpradio) #14

Literally. Go to your site, click Signup/Login and create a new account while having the Dev Tools open so you can see what data was posted to your site. That way you know what parameters to use for your API.


(Amandeep Singh) #15

Hi, My problem is solved. there is a field name: Community Type and this is required. Please update me what name is have to you for Community Type


(Vinoth Kannan) #16

I think custom user fields will be posted like ‘user_fields[1]’, ‘user_fields[2]’, etc., Not like ‘Facebook’, ‘Twitter’…

So he suggesting you to find ids from Signup/Login forms by sending some sample data. Alternatively you can do it in user preferences page too.


(Amandeep Singh) #17

Not working custom field like:

$params = array(
            'name' => $name,
            'username' => $userName,
            'email' => $emailAddress,
            'password' => $password,
            'active'=>'true',
            'user_fields[1]'=>'Other'
            
        );

(Vinoth Kannan) #18

Can you share your signup url?


(cpradio) #19

If you follow my instructions, they will help you figure out the name you are to use. We can’t possibly know that without using the dev tools and monitoring an actual sign up request.


You have not completed all the user fields API error
(Amandeep Singh) #20

I am not getting which signup url i have to provide to you becuase i am create user using PHP api.