[英]Detect Admin in frontpage of Opencart 2.3
For whole day I'm trying to find a way to detect that you are logged as Admin in backend while you are displaying the front page. 一整天,我试图找到一种方法来检测您在显示首页时在后台以管理员身份登录。 ( Opencart v 2.3 ).
(Opencart v 2.3)。 Non of advices that i have found today works.. Is there any way to do that?
我今天没有发现任何建议都行得通..有什么办法可以做到这一点? It would be great if there was a function like in Wordpress is_admin()..
如果在Wordpress中有一个类似is_admin()的函数,那就太好了。
You should be in same browser. 您应该在同一浏览器中。 Now go to any controller and insert the code to check if user_id is set in the session.
现在转到任何控制器,并插入代码以检查是否在会话中设置了user_id。 For example: Go to catalog/controller/common/header.php
例如:转到catalog / controller / common / header.php
Inside the index() method add following code: 在index()方法内,添加以下代码:
if($this->session->data['user_id']){
echo 'Admin is logged in';
}else{
echo 'Admin is not logged in';
}
Another way initialize the user object and check with isLogged() method 初始化用户对象并使用isLogged()方法检查的另一种方法
$loggeduser = new Cart\User($this->registry);
if($loggeduser->isLogged()){
echo "Admin is in";
}else{
echo "Admin not in";
}
https://webocreation.com/blog/check-admin-logged-front-page-opencart-2-3 https://webocreation.com/blog/check-admin-logged-front-page-opencart-2-3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.