We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How do I get user info in EE3 in an extension?

Development and Programming

dmDev08's avatar
dmDev08
100 posts
10 years ago
dmDev08's avatar dmDev08

I’m listening to the hooks “sessions_start” and “cp_member_login”. I want to be able to know on every CP page:

  1. The current logged in user
  2. What member group they’re in
  3. What they have access to

And possibly other info. How do I get this?

I tried using the session object passed by the hook, but the info was all empty.

public function listenToSession($sess)
{
    //This is false
    $userName = $sess->userdata[ "username" ];

    //These are both empty
    $memberId = $sess->sdata[ "member_id" ];
    $sessionId = $sess->sdata[ "session_id" ];
}
       
Kevin Cupp's avatar
Kevin Cupp
791 posts
10 years ago
Kevin Cupp's avatar Kevin Cupp

sessions_start may fire too early, can you use sessions_end?

       
dmDev08's avatar
dmDev08
100 posts
10 years ago
dmDev08's avatar dmDev08
sessions_start may fire too early, can you use sessions_end?

Will that fire early enough that I can execute a redirect if needed?

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

Yes, it’s at the end of the instantiation of the session, but is still a very early hook.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.