Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any hooks to alter the Services modules output. For eg : If I get a result like this for a file object.

  "fid": "132",
  "uri": "public:\/\/512dab4918036.jpg",
  "filename": "512dab4918036.jpg",
  "filemime": "image\/jpeg",
  "uid": "1",
  "status": 1,
  "timestamp": 1361947464,
  "filesize": 2521,

I want to limit it for users with certain roles.

I am looking for this as I have made many services resource manually so I don't want to edit them all and simply use the output alter hook to do something.

Is it possible ?

share|improve this question
What exactly do you want to do ? Remove some of the fields in the file object ? – drcelus Feb 27 '13 at 13:45
@drcelus no i want to deliver a default output if user dont met certain criteria. – niksmac Feb 27 '13 at 14:13
up vote 4 down vote accepted

The available hooks for Services are documented in the api docs for services

You probably want hook_services_request_postprocess_alter($controller, $args, $result); which allows you to change the array of $result any way you want.

share|improve this answer
may i know how to use "hook_services_request_postprocess_alter" .I have field called 'body' in $result ,I want to wrap it with CDATA.Any idea how to do it? &$result[0]->body is my variable – rks Mar 21 at 11:31
I assume you mean you don't know how to implement a hook? If you have a module named mymodule, you would implement a function called mymodule_services_request_postprocess_alter() with the arguments described above. More on Drupal's (pretty weird) hook system is at drupal.org/node/292 – rfay Mar 23 at 14:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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