We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17207
    • 23 Posts
    Hello guys,

    I’m using Login in Revo.
    I’ve been trying to hook a plugin to the OnWebLogin event to sync a custom user table with modx user data.
    The weird part is when I check $modx->getLoginUserId() and $modx->getLoinUserName, the values are the expected,
    but when I try accessing the data from $modx->user two things can happen:

    1- If I’m logged in the manager I get the managerUser info currently logged in;
    2- If I’m not logged (in the manager) I get errors trying to access the values ($modx->user doesn’t get set apparently, haven’t checked yet)

    a - What am I doing wrong? / How can I get the currently logging-in user data?
    b - Is this the right event to hook this plugin?
    c - what are the objects available at this "early" stage?

    One suggestion: It would be awesome to have a bit more documentation on the Login snippet events.

    Thanks.
    Diego
      • 17207
      • 23 Posts
      After a lot of tinkering... I opted for the easy way out: (all in the plugin hooked to OnWebLogin)

      $curUser = $modx->getObject($modx->getLoginUserId());


      Somehow on the frontend at this stage (WebLogin) $curUser is not equal to $modx->user.
      I thought these objects would have the same content.

      If someone can explain this I would appreciate.

      Thanks.
        • 10159
        • 1 Posts
        I know this is an old thread, but I was having problems doing this too so hopefully this is useful for someone.

        I couldn’t get the easy way out solution above to work for me, so here’s what I put in my plugin hooked to OnWebLogin:

        $username = $modx->db->escape($_POST['username']);
        $user = $modx->getObject('modUser', array('username' => $username));
        $userId = $user->get('id');
        

          Nathan Fitzgerald
          http://frequency9.net/