Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By Visgario on
Hi everybody,
I try to create a new user when saving a new node. But I can't set the user's password.
Here is how I try to process it:
1- user data are typed in a node
2- Rules: after saving the nodes (event), Rules creates a new entity: user (action)
I tried to add another Rules action: "Set a data value". But there is no "password" token.
Any ID about how to set the password ?
I have very little programming skills, so I prefer to user the Rules interface rather than code.
Configuration:
Drupal 7.9
Entity API 7.x-1.0-beta11
Rules 7.x-2.0
Comments
Had the same problem today,
Had the same problem today, here is my solution:
I realize you say you have little programming skills, but here is a simple snippet to do exactly what you want (and some more):
Hope that helps!
I Try to apply this code for
I Try to apply this code for Rules but no success, I changed $entity_created by $user_created but still no result! (Drupal 7.21)
After I created a new user
After I created a new user with rules I send an email with the token [entity-created:one-time-login-url] so the user can login and set there own password.
My implimentation
Hi all,
I needed to set the user's password whilst running a Rule and have broken the code by eiriksm (thanks!) down a little further. My process was to:
a) create user entity ($newuser)
b) set a rules variable $password (use PHP code to generate a random string)
c) execute custom PHP which looks like
This way you can also use the variable $password in say, an email to the user letting them know what their automatically generated password is.
Hope that helps someone.
BC
YESSS!
It sure did! Thanks a million!
As a custom Rules action
Thank you for the code above. It inspired this custom Rules action which accomplishes the same thing, but this way PHP doesn't need to be entered in the Rules interface, and the PHP Filter doesn't need to be enabled. Paste the following into a custom_module.rules.inc file.
How to use the above code?
Hi,
Regarding the above custom code shared by "ShaunDychko".... How do I actually use it?
I save the code in "custom_module.rules.inc" and then where to save this file at? "C:\xampp\htdocs\drupal\sites\all\modules\rules\modules?"
I would like to try this solution. Kindly advise.
custom_module
I realise this is an old question but: You'd save custom_module.rules.inc in a "custom_module" folder (eg sites/all/modules/custom_module) along with a "custom_module.info" and a "custom_module.module" file.
If that doesn't mean anything, I'd suggest a quick read through the documentation on on Creating custom modules.
++Andy
Developing Drupal websites for Livelink New Media since 2008
Worked great, thanks!
Worked great, thanks!
Thanks
Worked like a charm.
Thanks