Send Registration Email to the Admin

Send registration email to the admin (or anyone else) rather than the user


This article is going to be short and sweet. In it, we'll see a way to send the MODX Register snippet's email to the admin (or anyone else) instead of to the user. The Register snippet is part of the Login extra package.


MODX logo

The Problem

Suppose that you want to let users fill out a Registration form on your site, but don't want to send them an email that would let them activate their membership immediately after doing so. Maybe you're getting a lot of spam-bot registrations. Or maybe you only want to register your friends, or some other group of people you know. Some businesses only want to register people they recognize as existing clients.

The problem is that as soon as the form is filled you, the user gets a registration email and can activate their membership. You can stop the email from going out altogether, but that means finding the user in the user list and activating them manually on the Create/Edit User page.

What if you want the convenience of the link in the registration email without involving the user?


The Solution

It's not very difficult to modify the code to send the registration email somewhere else (if you can find it -- it's actually in the core\components\login\processors\register.php file in the Login package). The trouble with this is that your change will be overwritten if you ever update the Login package.

While searching for that code to make the change for a client, I stumbled across an undocumented property that sets the target address for the activation email: &activationEmail. So, to send the activation email somewhere else rather than to the user, you just need to add that property to the Register snippet tag:

&activationEmail=`somebody@gmail.com`

You may have to manually delete the files in the core/cache directory to make it take effect, but once it does, all activation emails will go to the address you specify. Better yet, all the admin needs to do to activate the user, is click on the link in the email.

Enhancements

Once the user is activated, you need to let them know, and typically, provide a link to the Login page. Rather than do this manually, you could forward the email to the user and let them activate themselves, but I prefer something a little slicker. You can install the ActivationEmail extra. It will execute automatically when the admin activates the user by clicking on the link in the activation Email. That way you can create a Tpl chunk with placeholders for the user, a link to the Login page, and anything else you want. Remember that you specify this email TPL chunk in the properties of the ActivationEmail plugin (preferably in a Property Set). See the ActivationEmail documentation for details. As soon as the user is activated, they will get that email.

 

For more information on how to use MODX to create a web site, see my web site Bob's Guides, or better yet, buy my book: MODX: The Official Guide.

Looking for high-quality, MODX-friendly hosting? As of May 2016, Bob's Guides is hosted at Hosting.com (formerly A2 Hosting). (More information in the box below.)



Comments (0)


Please login to comment.

  (Login)