I am able to get the response after register using service register.json


        "uid": "10",
        "uri": "http://example.com/apps_api/user/10"


{ "name":"smart", "pass":"smart", "mail":"[email protected]", "status":"1", "roles":[ "3" ] }

I get all the information "uri": "http://example.com/apps_api/user/10" . I just want to get the "name", "mail", "role" in response.

Do not need to go again "uri": "http://example.com/apps_api/user/10".

2 Answers 2


Add custom code/module to modify the service response, check hook_services_endpoint_response_alter and all other similar alter hooks services alter hooks


function MODULENAME_services_request_postprocess_alter($controller, $args, &$result) {
  if ($controller->callback == '_user_resource_create') {
    if ($result->uid) {
      $user = user_load($result->uid);
      $result->user = $user;
  • Thanks for response. Can you please explain little bit more.
    Jan 12, 2016 at 14:43
  • give me a min, sharing a working example, also it will be hook_services_request_postprocess_alter
    – nikunj
    Jan 12, 2016 at 14:48
  • check e.g. code
    – nikunj
    Jan 12, 2016 at 15:07
  • Add the code but still getting same response. No change in Response.
    Jan 12, 2016 at 15:20
  • change MODULENAME and clear cache, also which API are you using exactly? check the condition for $controller->callback
    – nikunj
    Jan 12, 2016 at 15:56

I was never able to get back the raw text password without hacking on the logintoboggan / user modules themselves (similar to what is shown in my question).

However, I solved my same purpose of providing immediate-login-upon-registration for Services/API calls using the services_token_access module. This code only hooks onto a success registration then ads the services_token to the response which is now the only thing my client now needs for validation.

function HOOK_services_request_postprocess_alter($controller, $args, &$result) {

if ( gettype($result) == 'array' && isset($result['uri']) && isset($result['uid'])) { // THIS CONDITION MATCHES THE DEFAULT RESPONSE OF A SUCCESSFUL REGISTRATION. 
        $user = (object)$result;
        $user = user_load($user->uid);
        $user = HOOK_services_account_object_alter($user);
        $result = array('token'=>$user->services_token, 'user'=>$user);

function HOOK_services_account_object_alter(&$user) {
    $user->services_token = services_token_access_update_token($user->uid, FALSE); // essential for logging in later
    $user->specialstuff = 'whatever else you need';

(The services_token_access module is not particularly popular and barely supported, but worked for me.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.