I am using Drupal 7 for my website. I have two roles administrator and IT. I want to add auto generate password link at the time change the password by superadmin or IT role and also send the mail to respective user.

Please help how to add this functionality in my site.

  • Please any one suggest me – Ankit Gupta Aug 6 '16 at 6:03

You can used hook_user_presave() to get the changed password in your module:

function mymodule_user_presave(&$edit, $account, $category){
 echo $_REQUEST['pass']['pass1'];

and use the functions hook_mail() & drupal_mail() to send the email in hook_user_presave() with the changed password in $_REQUEST['pass']['pass1'].

| improve this answer | |
  • Hi, Brian i am new in drupal so please let me know full process – Ankit Gupta Aug 17 '16 at 6:40
  • You need a custom module that uses hook_user_presave() (to intercept password), hook_mail() (to define custom email), & drupal_mail() (to send mail in mymodule_user_presave). You can Google "Drupal 7 tutorial custom module" & "Drupal 7 drupal_mail" on how to do that. There are many. – Brian Young Aug 18 '16 at 17:58

I have implemented this functionality using Password Quick Set module and doing a little bit of custom code.

| improve this answer | |

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.