Customizing user module output I am using Drupal 7 to develop a REST API to create an iPhone app. The basic feature for this app user login and logout process. I am using the User module. The authentication process involved is session authentication. JSON is the output format used for the API.

How do I customize the JSON output from the login service? I am getting a bunch of other information which I don't require. I am not sure how to add more tags to the JSON format. Can anyone point me to the files where the information is?

For example, for a wrong username and password I get the following output:


  Status 401 Unauthorized - Wrong username or password  
  
  ["Wrong username or password."]


I would like to change the output to have something like {status: 0, message: 'Wrong username and passowrd'}.

Can anyone help me?
Use this for errors:

/**
 * Implements hook_rest_server_execute_errors_alter().
 *
 * Reformat error output.
 */
function up_coaching_rest_rest_server_execute_errors_alter(&amp;$error_alter_array, $controller, $arguments) {
  $error_alter_array['body_data'] = array(
    'success' =&gt; FALSE,
    'error' =&gt; $error_alter_array['body_data'],
  );
}


For success output you need clone needed resources from user resource definition.