Search code examples
eventsauthenticationpyrocms

Getting logged-in user details in post_user_login event in PyroCMS


How to get the details of the just logged-in user in the post_user_login event in PyroCMS?

What I have tried:

  1. $this->current_user does not work, unless page is refreshed, even though the controllers are inheriting Public_Controller or Admin_Controller, thus implying availability of $this->current_user (documentation).

Why do I need this:

  1. To get (at least) user id or profile id, so that I can fetch more details and take action.

Solution

  • $data = $this->ci->current_user ? $this->ci->current_user : $this->ci->ion_auth->get_user();
    

    Source: https://forum.pyrocms.com/discussion/25095/get-logged-in-user-in-post_user_login-event Author: andym