Skip to content

Instantly share code, notes, and snippets.

@boboldehampsink
Created November 7, 2013 10:21
Show Gist options
  • Save boboldehampsink/7352349 to your computer and use it in GitHub Desktop.
Save boboldehampsink/7352349 to your computer and use it in GitHub Desktop.
Enable this to automatically activate new registrations in the CP
<?php
namespace Craft;
class AutoActivatePlugin extends BasePlugin
{
function getName()
{
return Craft::t('Auto activate from CP');
}
function getVersion()
{
return '1.0';
}
function getDeveloper()
{
return 'Bob Olde Hampsink';
}
function getDeveloperUrl()
{
return 'http://www.itmundi.nl';
}
function init() {
if(craft()->request->isCPRequest()) {
craft()->on('users.onSaveUser', function(Event $event) {
// Only react on event of new user
if($event->params['isNewUser']) {
// Activate user
craft()->users->activateUser($event->params['user']);
}
});
}
}
}
@blcarson
Copy link

Could you get this to work for registrations from the front end instead of the CP?

Edit - looks like I just needed to change "isCPRequest" to "isSiteRequest"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment