I'm trying to create a new role using the drupal services module. I am able to update a user with an already created role but can't find a way to add a new role. I'd rather not build a custom service for this so wondering if anyone knows of a way to do this without resorting to that.


First of All you could create the custom resource in a custom module and enable it, for doing that follow that tutorial

Second in the callback function use that code to create a new role

$role = new stdClass();
$role->name = 'editor';
// $role->weight = 10;

Let the role name be an argument taken from the request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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