title: Suspend a Moodle user by using Web service API functions
body: <p>I am trying to suspend a user in Moodle by using  Moodle's  <a href="https://docs.moodle.org/dev/Web_service_API_functions" rel="nofollow">Web service API functions</a> in PHP.
  I can change user fields like firstname, but I am not capable to suspend the user.</p>
  
  <p>It always returns "null".</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  $serverurl = "http://localhost/web/moodle/webservice/rest/server.php?wstoken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&amp;wsfunction=core_user_update_users&amp;moodlewsrestformat=json";
  $params = "users[0][id]=4&amp;users[0][preferences][0][type]=suspended&amp;users[0][preferences][0][value]=true";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $serverurl);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  $response = curl_exec($ch);
  
  print_r($response);
  
  curl_close($ch);
  ?&gt;
  </code></pre>