Skip to content

Instantly share code, notes, and snippets.

@messyOne
Created October 10, 2012 09:17
Show Gist options
  • Save messyOne/3864303 to your computer and use it in GitHub Desktop.
Save messyOne/3864303 to your computer and use it in GitHub Desktop.
Insert user_id in user_role_linker
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