Magento 2 - How to get admin user role?Get admin detail via load by user_id in magento 2How to detect the Admin status of the current user?Redirect admin user based on roleHow to get magento user phone number?How to list all admin of a specific roleAccessing Magento admin cookie in a custom file inside a folderMagento 2: How to get admin user detail load by id?Create admin role and user by installergetData() of User created in backend with specific Role id onlyHow to restrict admin user to log in if already any user logged inAdmin role automatically unchecked when role is edited Magento 1.9How to add new field to Admin User Info in Magento 2?

Was there ever an axiom rendered a theorem?

Calculate Levenshtein distance between two strings in Python

How can I add custom success page

What is the offset in a seaplane's hull?

What is the command to reset a PC without deleting any files

Where else does the Shulchan Aruch quote an authority by name?

COUNT(*) or MAX(id) - which is faster?

If a centaur druid Wild Shapes into a Giant Elk, do their Charge features stack?

How to move the player while also allowing forces to affect it

Patience, young "Padovan"

Symmetry in quantum mechanics

Is Social Media Science Fiction?

Can the Produce Flame cantrip be used to grapple, or as an unarmed strike, in the right circumstances?

What are the advantages and disadvantages of running one shots compared to campaigns?

Should the British be getting ready for a no-deal Brexit?

Unbreakable Formation vs. Cry of the Carnarium

Why do we use polarized capacitors?

Can a planet have a different gravitational pull depending on its location in orbit around its sun?

Re-submission of rejected manuscript without informing co-authors

Lied on resume at previous job

Denied boarding due to overcrowding, Sparpreis ticket. What are my rights?

What to wear for invited talk in Canada

Why is my log file so massive? 22gb. I am running log backups

Are objects structures and/or vice versa?



Magento 2 - How to get admin user role?


Get admin detail via load by user_id in magento 2How to detect the Admin status of the current user?Redirect admin user based on roleHow to get magento user phone number?How to list all admin of a specific roleAccessing Magento admin cookie in a custom file inside a folderMagento 2: How to get admin user detail load by id?Create admin role and user by installergetData() of User created in backend with specific Role id onlyHow to restrict admin user to log in if already any user logged inAdmin role automatically unchecked when role is edited Magento 1.9How to add new field to Admin User Info in Magento 2?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3

















I want to get all information of user(admin) and I find this answer for M1:

To get an admin user role try (assuming that user is log in)



$admin_user_session = Mage::getSingleton('admin/session');
$adminuserId = $admin_user_session->getUser()->getUserId();
$role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole()->getData();


Now I want get this for Magento 2.0. And how to do ?










share|improve this question






























    3

















    I want to get all information of user(admin) and I find this answer for M1:

    To get an admin user role try (assuming that user is log in)



    $admin_user_session = Mage::getSingleton('admin/session');
    $adminuserId = $admin_user_session->getUser()->getUserId();
    $role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole()->getData();


    Now I want get this for Magento 2.0. And how to do ?










    share|improve this question


























      3












      3








      3










      I want to get all information of user(admin) and I find this answer for M1:

      To get an admin user role try (assuming that user is log in)



      $admin_user_session = Mage::getSingleton('admin/session');
      $adminuserId = $admin_user_session->getUser()->getUserId();
      $role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole()->getData();


      Now I want get this for Magento 2.0. And how to do ?










      share|improve this question


















      I want to get all information of user(admin) and I find this answer for M1:

      To get an admin user role try (assuming that user is log in)



      $admin_user_session = Mage::getSingleton('admin/session');
      $adminuserId = $admin_user_session->getUser()->getUserId();
      $role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole()->getData();


      Now I want get this for Magento 2.0. And how to do ?







      magento2 admin session user-roles






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 26 '16 at 9:33









      Dissanayake

      179112




      179112










      asked Feb 26 '16 at 8:46









      MrTo-KaneMrTo-Kane

      1,79662465




      1,79662465




















          2 Answers
          2






          active

          oldest

          votes


















          4














          You need to use DI in your class -

          1. add property of AdminSession class to class
          2. add including of the variable using dependensy injection:



          /**
          * @var MagentoBackendModelAuthSession
          */
          protected $_adminSession;

          public function __construct(
          MagentoBackendModelAuthSession $adminSession
          )
          $this->_adminSession = $adminSession;



          and then where you need to use it:



          public function someMethod()

          $roleData = $this->_adminSession->getUser()->getRole()->getData();
          $userData = $this->_adminSession->getUser()->getData();






          share|improve this answer























          • after I tried, have a problem below: Fatal error: Call to a member function getRole() on null in

            – MrTo-Kane
            Mar 1 '16 at 2:02












          • I want get admin session at front-end.

            – MrTo-Kane
            Mar 1 '16 at 2:13


















          0














          protected $_context ;

          public function __construct(
          MagentoFrameworkAppActionContext $context
          )
          $this->_context = $context;


          public function customfucntion()

          $auth = $this->_context->getAuth();
          $loginUser = $auth->getUser();
          $loginUserRole = $loginUser->getRole();
          $loginUserRole->getRoleName();






          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103582%2fmagento-2-how-to-get-admin-user-role%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            You need to use DI in your class -

            1. add property of AdminSession class to class
            2. add including of the variable using dependensy injection:



            /**
            * @var MagentoBackendModelAuthSession
            */
            protected $_adminSession;

            public function __construct(
            MagentoBackendModelAuthSession $adminSession
            )
            $this->_adminSession = $adminSession;



            and then where you need to use it:



            public function someMethod()

            $roleData = $this->_adminSession->getUser()->getRole()->getData();
            $userData = $this->_adminSession->getUser()->getData();






            share|improve this answer























            • after I tried, have a problem below: Fatal error: Call to a member function getRole() on null in

              – MrTo-Kane
              Mar 1 '16 at 2:02












            • I want get admin session at front-end.

              – MrTo-Kane
              Mar 1 '16 at 2:13















            4














            You need to use DI in your class -

            1. add property of AdminSession class to class
            2. add including of the variable using dependensy injection:



            /**
            * @var MagentoBackendModelAuthSession
            */
            protected $_adminSession;

            public function __construct(
            MagentoBackendModelAuthSession $adminSession
            )
            $this->_adminSession = $adminSession;



            and then where you need to use it:



            public function someMethod()

            $roleData = $this->_adminSession->getUser()->getRole()->getData();
            $userData = $this->_adminSession->getUser()->getData();






            share|improve this answer























            • after I tried, have a problem below: Fatal error: Call to a member function getRole() on null in

              – MrTo-Kane
              Mar 1 '16 at 2:02












            • I want get admin session at front-end.

              – MrTo-Kane
              Mar 1 '16 at 2:13













            4












            4








            4







            You need to use DI in your class -

            1. add property of AdminSession class to class
            2. add including of the variable using dependensy injection:



            /**
            * @var MagentoBackendModelAuthSession
            */
            protected $_adminSession;

            public function __construct(
            MagentoBackendModelAuthSession $adminSession
            )
            $this->_adminSession = $adminSession;



            and then where you need to use it:



            public function someMethod()

            $roleData = $this->_adminSession->getUser()->getRole()->getData();
            $userData = $this->_adminSession->getUser()->getData();






            share|improve this answer













            You need to use DI in your class -

            1. add property of AdminSession class to class
            2. add including of the variable using dependensy injection:



            /**
            * @var MagentoBackendModelAuthSession
            */
            protected $_adminSession;

            public function __construct(
            MagentoBackendModelAuthSession $adminSession
            )
            $this->_adminSession = $adminSession;



            and then where you need to use it:



            public function someMethod()

            $roleData = $this->_adminSession->getUser()->getRole()->getData();
            $userData = $this->_adminSession->getUser()->getData();







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 26 '16 at 14:12









            Kate SuykovskayaKate Suykovskaya

            14819




            14819












            • after I tried, have a problem below: Fatal error: Call to a member function getRole() on null in

              – MrTo-Kane
              Mar 1 '16 at 2:02












            • I want get admin session at front-end.

              – MrTo-Kane
              Mar 1 '16 at 2:13

















            • after I tried, have a problem below: Fatal error: Call to a member function getRole() on null in

              – MrTo-Kane
              Mar 1 '16 at 2:02












            • I want get admin session at front-end.

              – MrTo-Kane
              Mar 1 '16 at 2:13
















            after I tried, have a problem below: Fatal error: Call to a member function getRole() on null in

            – MrTo-Kane
            Mar 1 '16 at 2:02






            after I tried, have a problem below: Fatal error: Call to a member function getRole() on null in

            – MrTo-Kane
            Mar 1 '16 at 2:02














            I want get admin session at front-end.

            – MrTo-Kane
            Mar 1 '16 at 2:13





            I want get admin session at front-end.

            – MrTo-Kane
            Mar 1 '16 at 2:13













            0














            protected $_context ;

            public function __construct(
            MagentoFrameworkAppActionContext $context
            )
            $this->_context = $context;


            public function customfucntion()

            $auth = $this->_context->getAuth();
            $loginUser = $auth->getUser();
            $loginUserRole = $loginUser->getRole();
            $loginUserRole->getRoleName();






            share|improve this answer



























              0














              protected $_context ;

              public function __construct(
              MagentoFrameworkAppActionContext $context
              )
              $this->_context = $context;


              public function customfucntion()

              $auth = $this->_context->getAuth();
              $loginUser = $auth->getUser();
              $loginUserRole = $loginUser->getRole();
              $loginUserRole->getRoleName();






              share|improve this answer

























                0












                0








                0







                protected $_context ;

                public function __construct(
                MagentoFrameworkAppActionContext $context
                )
                $this->_context = $context;


                public function customfucntion()

                $auth = $this->_context->getAuth();
                $loginUser = $auth->getUser();
                $loginUserRole = $loginUser->getRole();
                $loginUserRole->getRoleName();






                share|improve this answer













                protected $_context ;

                public function __construct(
                MagentoFrameworkAppActionContext $context
                )
                $this->_context = $context;


                public function customfucntion()

                $auth = $this->_context->getAuth();
                $loginUser = $auth->getUser();
                $loginUserRole = $loginUser->getRole();
                $loginUserRole->getRoleName();







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 5 at 9:13









                laxitalaxita

                114




                114



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103582%2fmagento-2-how-to-get-admin-user-role%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Sum ergo cogito? 1 nng

                    419 nièngy_Soadمي 19bal1.5o_g

                    Queiggey Chernihivv 9NnOo i Zw X QqKk LpB