Skip to content

Instantly share code, notes, and snippets.

@messyOne
Created Oct 10, 2012
Embed
What would you like to do?
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