So, I was doing a bit of customization of a Couponic template where I wanted to add a squeeze box (a future post!), but I first needed to check if a user was logged in or not. I didn't want a logged in user to see the squeeze box so I needed to figure out how the framework checked if a user is logged in. Well, it's pretty simple (I've included a quick and dirty write to the browser console log for quick debugging) <?php $isUser = Yii::app()->user->checkAccess('user'); if(!$isUser){ ?> <script> console.log("NOT A USER!!!!!!!!!!!!"); </script> <?php }else{ ?> <script> console.log("IS A USER!!!!!!!!!!!!"); </script> <?php } ?>
Developer Blog