Jump to content
adrian

Email New User

Recommended Posts

@adrian Sending copies to a list of users would certainly come in very handy! For debugging user registration scripts, I'd usually have to switch Bcc recipients regularly.

As for re-branding the Bcc option as "notify other users": sounds good, too. I'm fine with the way it works now and would see the ability to send multiple copies as a priority, but I certainly see your point in simplifying it.

  • Like 1

Share this post


Link to post
Share on other sites
20 hours ago, d'Hinnisdaël said:

@adrian Sending copies to a list of users would certainly come in very handy! For debugging user registration scripts, I'd usually have to switch Bcc recipients regularly.

As for re-branding the Bcc option as "notify other users": sounds good, too. I'm fine with the way it works now and would see the ability to send multiple copies as a priority, but I certainly see your point in simplifying it.

Ok, It now supports a comma-separated list of email addresses and it has been rebranded as "Notify Other Users" and it now uses "To" for sending to these addresses as well.

Please let me know if you see any problems.

  • Like 1

Share this post


Link to post
Share on other sites

Hi @adrian thanks for this great module.

I want to always show the "Send welcome message" field/checkbox for new users, that I create in the admin.
But this checkbox never shows. I filled out the email-address but it still does not show up.
I unchecked the option "Automatic Email Send" in the modules settings, because I want to choose if a user should get a welcome email or not.

Could this be because of the core version of PW that I am using? I am using 3.0.71 right now.

I turned on ProcessWire debug now, and EmailNewUser triggers an error:

Trying to get property of non-object in K:\xampp\htdocs\myproject\src\site\assets\cache\FileCompiler\site\modules\EmailNewUser\EmailNewUser.module on line 54

That line reads 

if ($this->wire('page')->process == "ProcessUser") $this->addHookAfter('ProcessPageEdit::buildFormContent', $this, 'addEmailFields');

I think the problem is 

$this->wire('page')->process == "ProcessUser"

but I am not sure. Any suggestions?

emailnewuser.png

  • Like 1

Share this post


Link to post
Share on other sites

Hi @jmartsch - glad you are finding it useful. 

I can't seem to reproduce any of the problems you are having

What version of the module are you running? Line #54 isn't that line in the current version, although it's only one off, so maybe it's a misreporting?

Do the various fields show when you have the automatic option check in the module config settings?

Also, what is it that you are dumping on line 72 that is returning "FieldtypePassword" ?

One thing to try here - can you change the:

public function init() {

on line 48 to:

public function init() {

}

public function ready() {

Yes, it is making the init function empty and converting the current init() function into a ready() function.

Please let  me know if that helps.

  • Like 1

Share this post


Link to post
Share on other sites

Hey @adrian. Thanks for your quick reply :)

42 minutes ago, adrian said:

Do the various fields show when you have the automatic option check in the module config settings?

 

No they did not show even when the option was checked.

Switching the init function to a ready function fixes the problem. I also thought of doing this, but didn't do it.
Now it is working fine :)

42 minutes ago, adrian said:

What version of the module are you running? Line #54 isn't that line in the current version, although it's only one off, so maybe it's a misreporting?

 

I use the latest version from github = 1.0.5 and if I open the file in a texteditor or in my IDE then line 54 is the correct line.

EDIT: Weird, on github it is line 55. Must be something in my editors.

Regarding the output of line 72 (that was something that I added):

bd($event->object->attributes["class"]);

There is a problem with removing the required attribute from password fields. It gets removed, but if you accidentally enter something in the password field and then delete it, you can not submit the form, because the required attribute gets added back in. This is coming from the InputfieldPassword.js which gets added to the page. Starting in line 120 it reads

$input.on('change', function() {
			var val = $(this).val();
			if(val.length > 0) {
				$input.attr('required', 'required');	
				$confirm.attr('required', 'required');
			} else if(!$(this).closest('.InputfieldStateRequired').length) {
				$input.removeAttr('required');
				$confirm.removeAttr('required');
			}
		});

So if the "Generate Password" Option is set, the script should not be executed or loaded.

One approach would be, to remove the CSS class "InputfieldPasswordComplexify" so the script does not react to it.

I tried to make a hook for this, but it does not work yet. Maybe you have some suggestions?

Here is my hook in the ready function:

$this->addHookBefore('InputfieldPassword::render', $this, 'removeComplexify');

and here the function

 protected function removeComplexify(HookEvent $event)
    {
        $f = $event->object;
        bd($f);
        $f->removeClass('InputfieldPasswordComplexify');
    }

I don't know what is wrong or if this is the right approach. I even tried to use addHookAfter, which also did not work. 

Maybe you have an idea?!

  • Like 2

Share this post


Link to post
Share on other sites

Wow, thanks for noticing that issue when manually entering and deleting a password - I had never come across that before.

The reason that "before" hook doesn't work for is because the InputfieldPassword::render() method uses addClass('InputfieldPasswordComplexify'), so you are removing it before it's actually added. I have achieved the same thing though with a str_replace on an "after" hook - not as elegant, but works fine.

You actually got me thinking about the whole approach to automatically generating the password and I thought it might be better to actually populate the fields when creating the user, rather than leaving them blank and populating when publishing the user.

I am going to PM you my current dev version to take a look at as see what you think of this new approach.

Thanks again for your help/feedback with this!

  • Like 1

Share this post


Link to post
Share on other sites

Ok, I have committed a new version which fixes the two bugs that @jmartsch reported.

As mentioned above, I have also revamped the password generator - it now populates the password fields while you are creating the user and the generated password matches the options defined in the PW "pass" field's config settings. The only one I can't match is the complexity factor, but so long as you stick to the default (or lower) it should all be fine - thanks to @Robin S's Password Generator (https://processwire.com/talk/topic/17406-password-generator/) for some inspiration :) 

Please let me know if you notice any problems with this new version.

  • Like 2

Share this post


Link to post
Share on other sites

Hey @adrian. I installed the new version from Github. There is a small bug that I found:

If I create a user and don't send him a welcome message, then the next time I edit this user (maybe I want to add some details to custom fields) the label of the email function reads "Re-send welcome message" although I did not send an email yet.

Feature request:

If "Generate password" is checked, and the "PasswordForceChange" module is installed, the checkbox "Force password change on next login" should be checked, because it is not save, to send passwords via email. But maybe that is just my opinion. What do you think of that?

  • Like 1

Share this post


Link to post
Share on other sites

Here is another one: If I create a user via the API and use $new_user->sendEmail = true; an email is not being sent.

Here is the code that I execute via Tracy console:

$new_user = new User();
$new_user->of(false);
$new_user->addRole("editor");
$new_user->email = "aceman3000@gmail.com";
$new_user->name ="aceman3000-gmail.com";
$new_user->sendEmail = true;
$new_user->save();

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi @jmartsch - looks like those recent changes broke a few things - sorry about that, but thanks for testing. Taking a look now.

Share this post


Link to post
Share on other sites

Ok @jmartsch, getting through these:

3 hours ago, jmartsch said:

If I create a user and don't send him a welcome message, then the next time I edit this user (maybe I want to add some details to custom fields) the label of the email function reads "Re-send welcome message" although I did not send an email yet.

Not sure how to handle this - the label changes from "Send" to "Resend" once the user has been published. I don't otherwise store a record of the email being sent. Sure it's possible, but I think it might get unnecessarily complicated. Do you have any thoughts for how it could be implemented well?

 

4 hours ago, jmartsch said:

Feature request:

If "Generate password" is checked, and the "PasswordForceChange" module is installed, the checkbox "Force password change on next login" should be checked, because it is not save, to send passwords via email. But maybe that is just my opinion. What do you think of that?

EmailNewUser respects the "Automatic Force Change" option in the PasswordForceChange module which ensures it is automatically checked when a new user is created. Does that work for you? I am hesitant to override that setting if it's intentionally unchecked. What do you think?

 

4 hours ago, jmartsch said:

Another bug: If you choose to re-send the welcome message, a new password is not generated.

Thank you - that is a new bug - because the password was populating the pass fields, rather than being generated on publish. Now it will generate if nothing is already set, which is the case when re-sending the welcome message.

 

4 hours ago, jmartsch said:

Here is another one: If I create a user via the API and use $new_user->sendEmail = true; an email is not being sent.

Here is the code that I execute via Tracy console:


$new_user = new User();
$new_user->of(false);
$new_user->addRole("editor");
$new_user->email = "aceman3000@gmail.com";
$new_user->name ="aceman3000-gmail.com";
$new_user->sendEmail = true;
$new_user->save();

 

Thanks - there are two things going on here. I broke this when I moved all the hooks yesterday from ready() to init(). I have fixed this now, but the other thing is that you are missing this:

$modules->get("EmailNewUser"); // call the module since it is not autoload on the front end

I just tested with your code with this on top in Tracy's console and it's now working fine.

Please test the latest version and let me know how you go.

Share this post


Link to post
Share on other sites
22 minutes ago, adrian said:
4 hours ago, jmartsch said:

Feature request:

If "Generate password" is checked, and the "PasswordForceChange" module is installed, the checkbox "Force password change on next login" should be checked, because it is not save, to send passwords via email. But maybe that is just my opinion. What do you think of that?

EmailNewUser respects the "Automatic Force Change" option in the PasswordForceChange module which ensures it is automatically checked when a new user is created. Does that work for you? I am hesitant to override that setting if it's intentionally unchecked. What do you think?

Actually, maybe the solution here is another config setting in EmailNewUser. The setting would force automatic selection of "Force password change on next login", even if the "Automatic Force Change" option isn't checked in the PasswordForceChange module. Do you think this would work ok?

Share this post


Link to post
Share on other sites

Hey @adrian. The password generation in the latest version does not work correctly. It only generates passwords that are 1 char long.

In line https://github.com/adrianbj/EmailNewUser/blob/master/EmailNewUser.module#L158 you generate the new password. The output of 

bd($this->wire('fields')->get('pass')->minlength);

is null. If I try to insert a number instead, it works.

 $newPass = $this->passwordGenerator(6, false, $this->buildPasswordCharacterSets($this->wire('fields')->get('pass')));

I get back to the other questions soon.

Share this post


Link to post
Share on other sites

Hi @jmartsch - I can't seem to reproduce this - it always returns the correct value from the "pass" field's settings. I tried an API send and a Re-send message and they both returned 10 correctly.

In my case it is set to 10. Any chance your pass field is set to 1, or it's not named "pass".

What happens if you do: 

d($fields->get('pass')->minlength);

in the Tracy Console panel?

59f72a3c2a01d_ScreenShot2017-10-30at6_33_26AM.png.548dc5754c150787540faa72378716b0.png

Share this post


Link to post
Share on other sites

Actually, I think there is a bigger issue at hand - setting the password generator to less than 8 characters results in "too weak" from the PW password validation, so I am going to force the number of characters higher for the automatic generation. After all,  this is only meant to be a temporary password so probably no real need to worry because users will be copying/pasting anyway.

I'll commit an update shortly. Hopefully this will deal with your issue anyway, although it would still be nice to know why you are getting "1".

Share this post


Link to post
Share on other sites

Ok, new version committed. I am now forcing more complex password generation. Using the settings from the "pass" field just weren't working well - often not complex enough for the complexity validation, but should be good now.

Share this post


Link to post
Share on other sites

Adrian, thank you for your support. The new version is generating the password fine.

But now the problem is back that no email is being sent when I create the user via the API :(

Here is the code, that I used to test this:

$new_user = new User();
$new_user->of(false);
$new_user->addRole("editor");
$new_user->email = "someone@somewhere.com";
$new_user->name ="someone-somewhere.com";
$new_user->sendEmail = true;
$new_user->save();

In a fresh PW 3.0.80 install I tried the latest version 1.1.2 and the output of 

d($fields->get('pass')->minlength);

is still "null". If I output only the field, I get the following data (see screenshot).

chrome_2017-10-30_15-20-53.png

Share this post


Link to post
Share on other sites
1 minute ago, jmartsch said:

But now the problem is back that no email is being sent when I create the user via the API

Don't forget that you need: 

$modules->get("EmailNewUser");

Are you using that and it's still not working?

As for the minlength thing - I get the feeling that maybe you're using a version of PW without those newish settings? This is what I see.

59f73b7c92c94_ScreenShot2017-10-30at7_45_26AM.png.e8c36438f4fe522c8ea79eb3723896e3.png

 

Share this post


Link to post
Share on other sites

Thanks. I did not use 

$modules->get("EmailNewUser");

because I previously changed the module to autoload, but after the updates this setting was gone. Thanks for the hint.

I am using latest ProcessWire Dev version from Github which is 3.0.80

And my settings look like in my screenshot. I am on a Windows System if that matters. But I don't think so.

After going into the pass field and saving the settings my bar dump now shows the same settings as yours. But these settings seem to be not available by default.

image.png.9231233fce20266b31fbde4e0c6e8073.png

Share this post


Link to post
Share on other sites

Even when I use:

$modules->get("EmailNewUser");
$new_user = new User();
$new_user->of(false);
$new_user->addRole("editor");
$new_user->email = "someone@somewhere.com";
$new_user->name ="someone-somewhere.com";
$new_user->sendEmail = true;
$new_user->of(true);
$new_user->save();

in Tracy console, the mail is not being sent. Or do I do something wrong?

Share this post


Link to post
Share on other sites
9 minutes ago, jmartsch said:


 

because I previously changed the module to autoload, but after the updates this setting was gone. Thanks for the hint.

Glad that sorted things out. I could possibly make it optionally autoloaded on the frontend, but I figure that loading it manually like that is an acceptable approach - any strong thoughts on this?

9 minutes ago, jmartsch said:

After going into the pass field and saving the settings my bar dump now shows the same settings as yours. But these settings seem to be not available by default.

Interesting - is this site upgraded from an old PW version before these settings were available, or is it a new install? I wonder if that's the reason, but also wonder if it's something that the PW System Updater should have taken care of when you upgraded - maybe something to bring up with Ryan? Either way, it's good to know. I am no longer relying on these settings - all I am doing now is adding "symbols/puctuation" if selected, and using a higher min password length if it's set higher than the 12 which I am forcing as a minimum.

Share this post


Link to post
Share on other sites
5 minutes ago, jmartsch said:

Even when I use:


$modules->get("EmailNewUser");
$new_user = new User();
$new_user->of(false);
$new_user->addRole("editor");
$new_user->email = "someone@somewhere.com";
$new_user->name ="someone-somewhere.com";
$new_user->sendEmail = true;
$new_user->of(true);
$new_user->save();

in Tracy console, the mail is not being sent. Or do I do something wrong?

When I try that I get this error: 

Exception: Can’t save page 0: /admin/access/users/adrian5/: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved. [roles] on line: 500 in /Users/ajones/Sites/ecoreportcard/wire/core/PagesEditor.php

59f74094c5c5c_ScreenShot2017-10-30at8_08_50AM.png.5dc76bf037829fa5d1fc2a80af8e2819.png

 

So, it's pretty clear that you can't turn outputformatting back on before saving (line 9). Do you not see that error in the Tracy console output?

Share this post


Link to post
Share on other sites

Yes, I removed that line, but email is still not being sent.

I even set autoload to true in the settings file, but that changes nothing.

Don't know why the email is not sent

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 Mike Rockett
      Jumplinks for ProcessWire
      Release: 1.5.56
      Composer: rockett/jumplinks
      Jumplinks is an enhanced version of the original ProcessRedirects by Antti Peisa.
      The Process module manages your permanent and temporary redirects (we'll call these "jumplinks" from now on, unless in reference to redirects from another module), useful for when you're migrating over to ProcessWire from another system/platform. Each jumplink supports wildcards, shortening the time needed to create them.
      Unlike similar modules for other platforms, wildcards in Jumplinks are much easier to work with, as Regular Expressions are not fully exposed. Instead, parameters wrapped in curly braces are used - these are described in the documentation.
      Under Development: 2.0, to be powered by FastRoute
      As of version 1.5.0, Jumplinks requires at least ProcessWire 2.6.1 to run.
      View on GitLab
      Download via the Modules Directory
      Read the docs
      Features
      The most prominent features include:
      Basic jumplinks (from one fixed route to another) Parameter-based wildcards with "Smart" equivalents Mapping Collections (for converting ID-based routes to their named-equivalents without the need to create multiple jumplinks) Destination Selectors (for finding and redirecting to pages containing legacy location information) Timed Activation (activate and/or deactivate jumplinks at specific times) 404-Monitor (for creating jumplinks based on 404 hits) Additionally, the following features may come in handy:
      Stale jumplink management Legacy domain support for slow migrations An importer (from CSV or ProcessRedirects) Feedback & Feature Requests
      I’d love to know what you think of this module. Please provide some feedback on the module as a whole, or even regarding smaller things that make it whole. Also, please feel free to submit feature requests and their use-cases.
      Note: Features requested so far have been added to the to-do list, and will be added to 2.0, and not the current dev/master branches.
      Open Source

      Jumplinks is an open-source project, and is free to use. In fact, Jumplinks will always be open-source, and will always remain free to use. Forever. If you would like to support the development of Jumplinks, please consider making a small donation via PayPal.
      Enjoy! :)
    • By BitPoet
      As threatened in Ryan's announcement for 3.0.139, I built a little module for sliding toggles as a replacement for checkboxes. Styling of the input is CSS3 only (with all the usual caveats about older browsers), no JS necessary, and may still be a bit "rough around the edges", so to speak, since I didn't have much time for testing on different devices or brushing things up enough so I'd feel comfortable pushing it to the module directory. But here's the link to the GitHub repo for now:
      InputfieldSlideToggle
      Fieldtype and Inputfield that implements smartphone-style toggles as replacement for checkbox inputs. The visualization is CSS-only, no additional JS necessary.
      Status
      Still very alpha, use with caution!
      Features / Field Settings
      Size
      You can render the toggles in four different sizes: small, medium, large and extra large.
      Off Color
      Currently, "unchecked" toggles can be displayed either in grey (default) or red.
      On Color
      "Checked" toggles can be rendered in one of these colors: blue (default), black, green, grey, orange or red.
      Screenshots

      Some examples with checkbox label


      View all Size and Color Combinations
      Small toggles Medium toggles Big toggles Extra big toggles  









    • By Orkun
      Hi Guys
      I needed to add extended functionalities for the InputfieldDatetime Module (module is from processwire version 2.7.3) because of a Request of Customer.
      So I duplicated the module and placed it under /site/modules/.
      I have added 3 new Settings to the InputfieldDatetime Module.
      1. Day Restriction - Restrict different days based on weekdays selection (e.g. saturday, sunday) - WORKING

       
      2. Time Slots - Define Time slots based on custom Integer Value (max is 60 for 1 hour) - WORKING

       
      3. Time Range Rules per Weekday - Define a minTime and MaxTime per Weekday (e.g. Opening Hours of a Restaurant) - NOT WORKING PROPERLY

       
      The Problem
      Time Slots and Day Restriction working fine so far. But the Time Range Rules per Weekday doesn't work right.
      What should happen is, that when you click on a date, it should update the minTime and maxTime of the Time Select.
      But the change on the select only happens if you select a date 2 times or when you select a date 1 time and then close the datepicker and reopen it again.
      The time select doesn't get change when you select a date 1 time and don't close the picker.
      Here is the whole extended InputfieldDatetime Module.
      The Files that I have changed:
      InputfieldDatetime.module InputfieldDatetime.js jquery-ui-timepicker-addon.js (https://trentrichardson.com/examples/timepicker/) - updated it to the newest version, because minTime and maxTime Option was only available in the new version  
      Thats the Part of the JS that is not working correctly:
      if(datetimerules && datetimerules.length){ options.onSelect = function(date, inst) { var day = $(this).datetimepicker("getDate").getDay(); day = day.toString(); var mintime = $(this).attr('data-weekday'+day+'-mintime'); var maxtime = $(this).attr('data-weekday'+day+'-maxtime'); console.log("weekday: "+day); console.log("minTime: "+mintime); console.log("maxTime: "+maxtime); var optionsAll = $(this).datetimepicker( "option", "all" ); optionsAll.minTime = mintime; optionsAll.maxTime = maxtime; $(this).datetimepicker('destroy'); $(this).datetimepicker(optionsAll); $(this).datetimepicker('refresh'); //$.datepicker._selectDate($(this).attr("id"),date); //$.datepicker._base_getDateDatepicker(); // var inst = $.datepicker._getInst($(this)); // $.datepicker._updateDatepicker(inst); /*$(this).datetimepicker('destroy'); InputfieldDatetimeDatepicker($(this), mintime, maxtime); $(this).datetimepicker('refresh'); */ // $(this).datetimepicker('option', {minTime: mintime, maxTime: maxtime}); } } Can you have a look and find out what the Problem is?
      InputfieldDatetime.zip
       
      Kind Regards
      Orkun
    • By teppo
      This module tracks changes, additions, removals etc. of public (as in "not under admin") pages of your site. Like it's name says, it doesn't attempt to be a version control system or anything like that - just a log of what's happened.
      At the moment it's still a work in progress and will most likely be a victim of many ruthless this-won't-work-let's-try-that-instead cycles, but I believe I've nailed basic functionality well enough to post it here.. so, once again, I'll be happy to hear any comments you folks can provide
      https://modules.processwire.com/modules/process-changelog/
      https://github.com/teppokoivula/ProcessChangelog
      How does it work?
      Exactly like it's (sort of) predecessor, Process Changelog actually consists of two modules: Process Changelog and Process Changelog Hooks. Hooks module exists only to serve main module by hooking into various functions within Pages class, collecting data of performed operations, refining it and keeping up a log of events in it's own custom database table (process_changelog.) Visible part is managed by Process Changelog, which provides users a (relatively) pretty view of the contents of said log table.
      How do you use it?
      When installed this module adds new page called Changelog under Admin > Setup which provides you with a table view of collected data and basic filtering tools See attached screenshots to get a general idea about what that page should look like after a while.
      For detailed installation instructions etc. see README.md.
       


    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      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)
       




×
×
  • Create New...