July 10, 2020 yogesh

How to Get Admin User Data in Magento 2?

Hello Magento Folks,

Today We will discuss How to Get Admin User Data in Observer in Magento 2. Learn How to Add New Product Type in Magento 2 in our last published blog.

Magento allows for building events and observers. It is one type of Magento class where the created observer helps in identifying the performance, general behavior and to improve your business logic. Here, we will help you to get admin user data in the observer.

Steps to get admin user data in observer:

Step 1: Create events.xml file in your module at the below-given path:

Path: app\code\Webiators\AdminUserData\etc\events.xml

Step 2: Now create an observer file at the below path.

Path: app\code\Webiators\AdminUserData\Observer\Backenduserobserver.php

Now go to your Backend and try to login with your username and password, and navigate to your var/log directory you can see backend_auth_user_login_success.log file there with your user content.

That’s it!

Any doubts in the above method can be mentioned in the Comments section below.

Happy Coding!