title: I am trying to add a new user in moodle via webservice with custom fields
body: <p>I am trying to create a user in moodle via webservice .The user is created successfuly but the custom field is not filled.Can anybody redirect me towards the solution?In custom field i am trying to send value for gender as male.</p>
  
  <pre><code>       $functionName = 'core_user_create_users';
              $user1 = new stdClass();
              $user1-&gt;username = $form_state['values']['UserName']; 
              $user1-&gt;password=$form_state['values']['PassWord']; 
              $user1-&gt;firstname = $form_state['values']['FirstName']; 
              $user1-&gt;lastname = $form_state['values']['LastName']; 
              $user1-&gt;email = $form_state['values']['Emailid']; 
              $user1-&gt;mailformat = '0';
              $preferencename1 = 'auth_forcepasswordchange';
              $user1-&gt;preferences = array(
                  array('type' =&gt; $preferencename1, 'value' =&gt; 'true')
                 );
                $user1-&gt;customfields = array(
                  array('type' =&gt; 'Gender', 'value' =&gt; 'Male')
                 );
              $users = array($user1);
              $params = array('users' =&gt; $users);
  
              /// REST CALL
      $rest_format = 'json';
  
          //$server_url = $domain_name . '/webservice/rest/server.php' . '?wstoken=' . $token . '&amp;wsfunction=' . $function_name;
          $server_url = 'localhost/moodle' . '/webservice/rest/server.php'. '?wstoken=' . '7525ce057d455657a4e83d7aa63f3684' .'&amp;wsfunction='. $functionName;
          require_once('curl.inc');
          $curl = new curl;
          $rest_format = ($rest_format == 'json') ? '&amp;moodlewsrestformat=' . $rest_format : '';
  
          $resp =$curl-&gt;post($server_url.$rest_format , $params);
          dpm($resp);
          $res=json_decode($resp);
  
          dpm($res);
  </code></pre>