- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Magento 2 How to check if Admin Logged on frontend
Hi,
How to track all the Admin Activity on Frontend when he Logged In as Customer.
Please suggest any solution.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 How to check if Admin Logged on frontend
Use following code
protected $_customerSession; public function __construct( \Magento\Customer\Model\Session $customerSession, ) { $this->_customerSession = $customerSession; } public function getGroupId(){ if($this->_customerSession->isLoggedIn()): //Get current group echo $this->_customerSession->getCustomer()->getId(); // get customer id echo $this->_customerSession->getCustomer()->getName(); // get customer Full Name echo $this->_customerSession->getCustomer()->getEmail(); // get customer Email else: echo “no logged in”; endif; }
Problem solved? Click Accept as Solution!"
Qaisar Satti
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 How to check if Admin Logged on frontend
You have given the customer session, but i need the admin logged in as vendor in frontend.
And need to track the admin activity on frontend.
For Admin activity on Backend we are having a free extension KiwiCommerce_AdminActivity, but i need the track of admin on frontend when he logged in as customer.
Here first we need to carry admin session or anything (please suggest) to know that the logged into customer account is an admin.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 How to check if Admin Logged on frontend
@Kiran
If you are using marketplace extension then it is using the customer session not admin session. This is correct code for you. you can check it customer group is vendor. Then you track that user information.
Problem solved? Click Accept as Solution!"
Qaisar Satti
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 How to check if Admin Logged on frontend
Hi @qaisar_satti
When trying to use your code $customerSession i am getting the following Fatal Error:
Fatal error: Uncaught Error: Call to a member function create() on null
Please suggest.
And also can you help me with code for the below words:
you can check it customer group is vendor. Then you track that user information.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 How to check if Admin Logged on frontend
Following this tutorial you will get customer group information. As far error concern can you send or share code with me
current customer group
Problem solved? Click Accept as Solution!"
Qaisar Satti