SocialEngine Tutorial – Checking user authentication and administration privilages

Sometimes you’ll need to protect your controllers from non members. In order to do this you can use the code below in your action (controller class);

if(!$this->_helper->requireUser()->isValid()) return;

This will check that you have a valid user who is signed into the site. However if you want to check if the current user is an administrator you can use;

if(!$this->_helper->api()->user()->getViewer()->isAdmin()) return;