Created
November 7, 2013 10:21
-
-
Save boboldehampsink/7352349 to your computer and use it in GitHub Desktop.
Enable this to automatically activate new registrations in the CP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"