apeisa Posted November 15, 2012 Share Posted November 15, 2012 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™: Copy the file FieldtypeSendUserCredentials.module to /site/modules/ directory Install the module from Modules section Create new field, call it "send_password" or whatever you like to call it. Important: choose SendUserCredentials as a fieldtype Edit user template (if you can't find it, Filters => Show system templates) 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 5 Link to comment Share on other sites More sharing options...
apeisa Posted November 15, 2012 Author Share Posted November 15, 2012 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 More sharing options...
ryan Posted November 15, 2012 Share Posted November 15, 2012 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 More sharing options...
apeisa Posted November 15, 2012 Author Share Posted November 15, 2012 Thanks Ryan. Yeah, reset is the fieldname, was pretty confusing since I was using different field name on each example. Also removed the permanent (it got there from copying the core FieldtypeCheckbox module) Link to comment Share on other sites More sharing options...
ryan Posted November 16, 2012 Share Posted November 16, 2012 Great module! Post please post to modules.processwire.com at your convenience. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now