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;
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
add a comment |
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
add a comment |
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
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
magento2 admin session user-roles
edited Feb 26 '16 at 9:33
Dissanayake
179112
179112
asked Feb 26 '16 at 8:46
MrTo-KaneMrTo-Kane
1,79662465
1,79662465
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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();
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
add a comment |
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();
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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();
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
add a comment |
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();
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
add a comment |
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();
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();
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
add a comment |
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
add a comment |
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();
add a comment |
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();
add a comment |
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();
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();
answered Apr 5 at 9:13
laxitalaxita
114
114
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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