Created
October 10, 2012 09:17
Insert user_id in user_role_linker
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
public function onBootstrap($e) | |
{ | |
$app = $e->getTarget(); | |
$sm = $app->getServiceManager(); | |
$adapter = $sm->get('Zend\Db\Adapter\Adapter'); | |
// adding action for user registration | |
$zfcServiceEvents = $sm->get('zfcuser_user_service')->getEventManager(); | |
$zfcServiceEvents->attach( | |
'register.post', | |
function($e) use ($adapter) { | |
$user = $e->getParam('user'); // User account object | |
$id = $user->getId(); // get user id | |
$adapter->query( | |
'INSERT INTO | |
user_role_linker (user_id, role_id) | |
VALUES | |
(' . $id . ', "user")', | |
Adapter::QUERY_MODE_EXECUTE | |
); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment