Equity Posted June 16, 2021 at 06:31 PM Share Posted June 16, 2021 at 06:31 PM (edited) Hi, Could use some help figuring out a conditional to check if user is admin if not load something else for a JReviews controller.php template override. Have tried calling the Jfactory and S2Object::make('auth');. Its all confusing to me. <?php defined('MVC_FRAMEWORK') or die; //use Joomla\CMS\Factory; //use JFactory::getApplication(); Function myFunction() { if (defined('MVC_FRAMEWORK_ADMIN')) return; //$auth = S2Object::make('auth'); //$auth = Factory::getUser(); If ($auth->admin && $auth->connected) //do something or output something elseif !($auth->admin && $auth->connected) { //do something or output something } //Or this example If ($auth->isAdmin && $auth->connected) { //do something or output something elseif !($auth->isAdmin && $auth->connected) { //do something or output something } } } Thanks! DanielH Edited June 16, 2021 at 06:32 PM by Equity Link to comment
Alejandro Posted June 16, 2021 at 11:12 PM Share Posted June 16, 2021 at 11:12 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Equity Posted June 16, 2021 at 11:53 PM Author Share Posted June 16, 2021 at 11:53 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted June 17, 2021 at 12:12 AM Share Posted June 17, 2021 at 12:12 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Equity Posted June 17, 2021 at 01:39 AM Author Share Posted June 17, 2021 at 01:39 AM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Recommended Posts