cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 How to check if Admin Logged on frontend

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.

 

5 REPLIES 5

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;

}

Reference

Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

Re: Magento 2 How to check if Admin Logged on frontend

Hi @qaisar_satti

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.


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.

Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti

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. 

Re: Magento 2 How to check if Admin Logged on frontend

@Kiran

 

Following this tutorial you will get customer group information. As far error concern can you send or share code with me

current customer group

Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti