Automating member signup email

Concrete 5.6.4.0 (looking to upgrade next year)

I want create an automated email response for people registering on my site (using the built in registration system). The email will says thanks for registering as well as a password for CAD files they can download and use. Email also cc’d to me.

Any ideas please?

You can use the “on_user_add” event to handle this by

Adding the following line to your config/site.php file

define('ENABLE_APPLICATION_EVENTS', true);

Create a new file named site_events.php in the config/ directory and have this as the content:

<?php
Events::addListener('on_user_add', function($ui) {
	$emailBody = '<p>This is the html of the email the user will receive.</p>';

	$mh = Loader::helper('mail');
	$mh->from('SET_FROM_EMAIL_HERE');
	$mh->to($ui->getUserEmail());
	$mh->setSubject('SET_EMAIL_SUBJECT_HERE');
	$mh->setBodyHTML($emailBody);
	$mh->sendMail();
});

Do I have to change email serving to smtp method so this works? Or just use default?

SMTP is more reliable, but not required. It really depends on your server setup. This will send the email the same way that all other emails are sent from your site.

I have tested your code and when I log into the site as admin I get an error:

Call to undefined method Events::addListener()

Any ideas to fix pls?

Try switching addListener to extend but leave everything else the same

Now I get error when I changed addListener to the word event:

Call to undefined method Events::event()

@hutman said "Try switching addListener to extend … not event.
Events::extend()

Whoops! Sorry my lousy reading skills!