Register new user as authenitcated user in drupal using xml-rpc

209 views Asked by At

I'm trying to write PHP script for adding new users in drupal 7 using services module.

So far I managed to create one, but as a anonymous user. When I run the script with administrator only permissions, I get Notice:

Access denied for user anonymous (403), although I send the username and password in the request.

Any ideas what should I try to do?

Thank you in advance.

1

There are 1 answers

2
tyler.frankenstein On

You can't use the User Register service resource when logged in as any type of authenticated user. This is very similar to Drupal's default behavior in that when you're logged in, you can't fill out the registration form. Instead you need to call the User Create service resource.

Do a POST to ?q=[my-endpoint]/user.json and send along data similar to the following:

{ account: { name: 'bob', mail: '[email protected]', } }