3

I need to create a module that when visited with some get parameters in the url to be able to create user with specific roles in the database.

So if someone visits mydomain.com/my_custom_module/create/john/smith/role_id/filename_that_includes_hidden_token_for_validation

Will create the user John Smith with a role specified by the id passed and in order not to allow anyone to create users I have a temp txt file with a random generated name where I keep a token

Is that possible? Is there a better way?

Thanks in advance

EDIT

Why I want a module like this:

I have a site written in cakePHP and the need for a forum came up. The client heard that drupal's advanced forum is the best solution (I've tried to persuade him to use phpbb with no luck...) but he wants the forum to be private and to give access and roles to existing members from the cakePHP's site admin. So I'll provide him an "give forum access to member" button which will redirect to the url described above after I've created a temp file with a hidden token somewhere in the server for security issues. I don't know if it is the best way to do this.

  • does the role differ always in the URL ? or is it only 1 kind of role? – Hacker Jan 11 '12 at 12:45
  • There will be two kind of roles. Simple member and content editor – chchrist Jan 11 '12 at 13:04
2

That is no problem. user_save an hook_menu will be you're friends.

The file with the random is a good id for security. You could also have a look into the IP Login module.

| improve this answer | |
  • Does the user_save checks if the user exists and if not create him for me? I've updated the question with the setup I have now. – chchrist Jan 11 '12 at 13:13
  • You cannot create two users with the same name. Try loading the user first with user_load. However user_save allows you to save changes to the user account. See the parameter description of user_save. – BetaRide Jan 11 '12 at 15:18

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.