Jump to content
adrian

Email New User

Recommended Posts

This module allows you to automatically send an email to a newly created user with their username and password. It also has the option to automatically generate a password for the user upon creation.

http://modules.processwire.com/modules/email-new-user/

https://github.com/adrianbj/EmailNewUser

The following things are configurable:

  • Whether Send Email option should be automatically checked when creating new user - also affects new users created via API
     
  • From email address (if left blank it will use the admin email set in the config/php file
     
  • Email subject
     
  • Email body - includes the ability to use any fields from the user template using {field_name} codes so these can be put into the body wherever you want. It's your choice if you want to include the password in the email or not.
     
  • Whether to automatically generate a password. This can be toggled on/off, but even if it is on, you can override it by simply entering a password manually when creating the new user.
     
  • Ability to control the length and character sets used to make up the automatically generated password.
     
  • Option to send a test email to yourself to make sure it is configured the way you expect.

Because it is generally not a good idea to email passwords, it is highly recommended to use the new Password Force Change module in conjunction with this module. That way the user has to change their password the first time they login which will somewhat reduce the vulnerability of emailing the password.

post-985-0-79912800-1437180859_thumb.png

It can also be used for API generated users:

$modules->get("EmailNewUser"); // call the module since it is not autoload on the front end
$newuser = new User(); 
$newuser->name = 'newuser';
$newuser->email = 'newuser@gmail.com';
$newuser->sendEmail = true; // only needed if Automatic Email Send is unchecked
$newuser->save();

Please let me know if you have any ideas for improvements.

PS Thanks to everyone in this post: https://processwire.com/talk/topic/2981-new-user-welcome-message/ for their thoughts and ideas on how to do this.

  • Like 20

Share this post


Link to post
Share on other sites

Thanks adrian, not only for this new module but also for your

abundant supporting posts and contributions in this forum.

  • Like 9

Share this post


Link to post
Share on other sites

Because it is generally not a good idea to email passwords, it is highly recommended to use the new Password Force Change module in conjunction with this module. That way the user has to change their password the first time they login which will somewhat reduce the vulnerability of emailing the password.

I would be in favour of them choosing a password when signing up with an confirmation link in the email, assuming there was a signup form, however I appreciate that this module is limited ("focused" is probably a better word :)) in its scope and that my suggestion would be better suited to a wider user account module.

  • Like 1

Share this post


Link to post
Share on other sites
I would be in favour of them choosing a password when signing up with an confirmation link in the email, assuming there was a signup form, however I appreciate that this module is limited ("focused" is probably a better word  :)) in its scope and that my suggestion would be better suited to a wider user account module.

Hi Pete - that is exactly what I do with my front-end registration script, but this module is designed for backend creation of admin users. I have never facilitated user signup for admin accounts, but perhaps that is not a bad idea - a module that allows a user to signup for an account with their own details and then after email activation, the superuser gets an email with the new user's account edit link and then they go and make sure they are a valid user and then assign them the appropriate roles/permissions. Is that basically what you are suggesting?

Share this post


Link to post
Share on other sites

Just in case anyone was thinking this module forced you to send the user's password, I just wanted to clarify that if you don't want to email the password at all, that is no problem - the body of the email is completely configurable.

In the module config settings you create the message from scratch using any of the fields from the user's page however you want, so you could quite easily let your clients know their initial default password over the phone (potentially the same for each person in their team), but still have this module automatically send each user an email with their username and the link to the site's PW admin control panel.

Using this approach, together with Password Force Change, you'd have a very safe way of getting out the login details for the entire team of editors and making sure their passwords get immediately changed.

  • Like 2

Share this post


Link to post
Share on other sites

Minor, but important update today. This morning's commits to PW 2.4.17 made the password field required for new users, which broke this module when using the automatically generated password option. I just submitted a fix for this. Please let me know if you have any troubles.

  • Like 1

Share this post


Link to post
Share on other sites

Tried to install the module, got this:

Error: Class EmailNewUser contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Module::getModuleInfo)

Share this post


Link to post
Share on other sites

Tried to install the module, got this:

Error: Class EmailNewUser contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Module::getModuleInfo)

Sorry about that - I have just committed a fix that I think should take care of it. Please let me know if it works for you now.

Not sure why you got that error, but I have never seen it - maybe a PHP version difference?

Also, note that it requires PW dev due to the way I set up the module info in a separate file.

  • Like 1

Share this post


Link to post
Share on other sites

Adrian, i think this may be what I'm after through I've not had a chance yet to try it. I need to bulk import a number of users to become registered users. Could I import these users with csv to page and have this module email them their details?

Thanks

David

Share this post


Link to post
Share on other sites

Hi David,

There is definitely the possibility to do this, but depending on how you are doing the import I might need to tweak some things for you because the module is currently restricted to the admin template only. I did a test with creating a user via the API and the everything works as expected, so we should be good there.

How are you planning on importing? I tried Ryan's CSV importer, but it doesn't look like it will work for creating users because it doesn't have access to the name field of a page. Instead it uses the title, but user pages don't have a title field, so not sure how you could make it work. Also the issue of assigning roles to the imported users - again another strike for the CSV importer. So I think you'll need to write your own CSV import / user creation script - which should be fairly easy to do.

So anyway, once you have that up and running, let me know the exact mechanism and I'll do whatever might be needed to make this module play nicely for you.

It should also work well with the automatic password generation and combined with Force Password Change (http://modules.processwire.com/modules/password-force-change/) you should have a pretty easy method of setting up a large number of new users.

Anyway, let me know what you need.

Share this post


Link to post
Share on other sites

Hi David,

There is definitely the possibility to do this, but depending on how you are doing the import I might need to tweak some things for you because the module is currently restricted to the admin template only. I did a test with creating a user via the API and the everything works as expected, so we should be good there.

How are you planning on importing? I tried Ryan's CSV importer, but it doesn't look like it will work for creating users because it doesn't have access to the name field of a page. Instead it uses the title, but user pages don't have a title field, so not sure how you could make it work. Also the issue of assigning roles to the imported users - again another strike for the CSV importer. So I think you'll need to write your own CSV import / user creation script - which should be fairly easy to do.

So anyway, once you have that up and running, let me know the exact mechanism and I'll do whatever might be needed to make this module play nicely for you.

It should also work well with the automatic password generation and combined with Force Password Change (http://modules.processwire.com/modules/password-force-change/) you should have a pretty easy method of setting up a large number of new users.

Anyway, let me know what you need.

Ok, it's there!

Used Ryan's import users from CSV module. Added title to the users template which seems to duplicate in to the name field.My test csv looks like this:

title,pass,email,roles,,,,,

james,james,james@james.com,2107,,,,,

What's next?

Share this post


Link to post
Share on other sites

Well I just did some quick testing and things seem to work perfectly with all the emails being sent as soon as the CSV import is completed.

The only problem I noticed is getting the password into the email. If you don't populate the password via the CSV, and use the automatic password generation feature of my module, then it all works, but if you populate the email from the CSV, then my module doesn't have access to the password. Do the users already know their passwords? Could you use the automatic generation instead?

Let me know if you do need to import the passwords and I'll see what I can do about getting my module to grab these a different way - apparently the InputfieldPassword::processInput hook doesn't work in this situation.

The only other problem I noticed with the actual import was that I couldn't get the oles field to populate even though I added FieldtypePage to the array. Did the roles import work for you?

Share this post


Link to post
Share on other sites

Thanks so much.

I don't need to pre populate the passwords so I'm happy to have them generated by your module.

Yes, I did get the roles to import in the end.  It looks like this for me:

	protected $fieldtypes = array(
		'FieldtypePageTitle',
		'FieldtypeText',
		'FieldtypeTextarea',
		'FieldtypeInteger',
		'FieldtypeFloat',
		'FieldtypeEmail',
		'FieldtypeURL',
		'FieldtypeCheckbox',
		'FieldtypeFile',
		'FieldtypePassword', // add this line for passwords
		'FieldtypePage', // add this line for the roles
		);

I had to call the columns in the roles 'roles' and reference the role by ID rather than name

Share this post


Link to post
Share on other sites
I don't need to pre populate the passwords so I'm happy to have them generated by your module.

Great!

I had to call the columns in the roles 'roles' and reference the role by ID rather than name

I thought I did exactly the same - oh well so long as you have it working :)

I'd say install my module, run a test import of a few dummy users, all with your email address to make sure it works as expected, and then you should be good to go.

I am heading out now for a bit but will get back to you later if you report any problems.

Share this post


Link to post
Share on other sites

PS I would recommend also installing: http://modules.processwire.com/modules/password-force-change/

This way the user will be required to change their automatically generated temp password when they first sign in.

Make sure the role that you assign to each new user has edit-profile permission otherwise they won't be able to change their password!

Share this post


Link to post
Share on other sites

That's odd, on my playground site the module installed, but on the live site i got this error when installing it:

Error: Class EmailNewUser contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Module::getModuleInfo) (line 215 of /var/www/clients/client2/web37/web/site/modules/EmailNewUser/EmailNewUser.module) 

The site still functions but won't let me into the modules section without that message.

actually, happens on both upon install...

Edited by davo

Share this post


Link to post
Share on other sites

Sorry, I built the module using the new .info.json file for describing the module info which requires PW 2.4.3+

Upgrading to PW dev will fix it - keep in mind that 2.5 stable is slated for late this week, early next week, so there will be minimal changes before official release now. If you don't want to do that, just let me know and I'll quickly put together a version that will work just fine with 2.4 stable. The modules directory needs a dev option or at least a 2.x where x is the version after the current stable so people know a modules requires the dev version.

Edited by adrian

Share this post


Link to post
Share on other sites

I could upgrade my playground site early to test it all and then wait for the 2.5 stable release for the live site. Sound most sensible?

Share this post


Link to post
Share on other sites

I say go for it - there is certainly no reason to not be running the dev version on a test/dev site right now and if you find no problems, switch the live whenever you are ready.

Let me know how it goes - I think it would be nice to write up a tutorial for this when you're done to describe all the steps and any changes needed to the CSV importer to make it all work. I am actually tempted to build something specific to importing and emailing users, but maybe if we can have a clear step-by-step that will be fine too.

  • Like 1

Share this post


Link to post
Share on other sites

Success on playground site -

Deleted module

Upgraded pw to dev branch

installed new user email module

installed import pages from CSV

edited the module to include additional protected fields

successfully imported user from CSV and welcome email sent!

Thank you. When I do the live site I'll try and video the process for others.

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

I'm trying to get back to this again now. It's not currently sending emails for new users. Do you think it would be a good idea to in the module settings to add a 'send test email' button?

Share this post


Link to post
Share on other sites

Hi davo,

Pretty busy here this morning, so just a quick reply to say that I think email test sending is probably better left to one of the WireMail modules: http://modules.processwire.com/modules/wire-mail-swift-mailer/ or http://modules.processwire.com/modules/wire-mail-smtp/

I think they both have a test send function, although there might be some reliability issues with that - there is a couple of posts about that on the support thread for the latter module (the one by horst).

Are you getting any emails sent from your site at all? If any work, then the ones from this module should work fine.

Let me know how you go and I'll try to have more input later.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. 
      EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant  
      Changelog
      004 (current version)
      - Make rounding of manually entered values configurable (floor, round, ceil or disable)
      - Fix small JS bug when the value-display field was not displayed
      - Update README
      003
      - Code cleanup, add some ModuleInfo data & LICENSE
      - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/)
      002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional
      001
      - Initial release
       
      Thanks!
       
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
×
×
  • Create New...