Jump to content

Module: Send User Credentials


apeisa
 Share

Recommended Posts

This module tries to help in very common admin task: emailing user a new password. I implemented this as a fieldtype, not sure if that is best way to go? I did it that way to allow simple API usage and offering easy customization (like in what position to put the reset checkbox etc).

Simple Five Steps installation™:

  1. Copy the file FieldtypeSendUserCredentials.module to /site/modules/ directory
  2. Install the module from Modules section
  3. Create new field, call it "send_password" or whatever you like to call it. Important: choose SendUserCredentials as a fieldtype
  4. Edit user template (if you can't find it, Filters => Show system templates)
  5. Add new field there

Usage from admin:

Edit user and check the new field. Save.

Usage from API:

$u = $users->get("apeisa");
$u->of(false);
$u->send_password = 1; // send_password = whatever you have named your new field
$u->save();

TODO:

  • Offer better security by requiring password change right after login

EDIT:

  • Removed the permanent
  • Added few comments and better usage from API instructions

FieldtypeSendUserCredentials.module

  • Like 5
Link to comment
Share on other sites

This fieldtype wouldn't even need a db-table, since value is always 0 (well, it is 1 at the runtime but that will never get saved). So there probably is some code that can be removed (this was build from Checkbox fieldtype).

Link to comment
Share on other sites

Great idea! Thanks for making this, it's very useful.

In your API example, it says "$u->reset = 1;", is "reset" the name of the field, or is that a static name to always use?

Also wanted to suggest removing the "permanent=true" from your getModuleInfo() because that will prevent people from being able to uninstall it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...