We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31900
    • 3 Posts

    How do i grab the event’s params from a plugin? i notice in the core ’save_user.processor.php’, the following happen for event OnWebChangePassword::

    $modx->invokeEvent("OnWebChangePassword", array (
    				"userid" => $id,
    				"username" => $newusername,
    				"userpassword" => $newpassword
    			));
    


    I want to get the username and the password that was passed in the event, so far this is what i have but its not working.
    $e = &$modx->Event;
    switch ($e->name) {
    case "OnWebChangePassword":
        sendResetLog($e->parseProperties("useremail"), $e->parseProperties("newusername"), $e->parseProperties("newpassword"), $e->parseProperties("fullname"));
        break;
    default :
        return; // stop here - this is very important.
        break;
    }
    
      • 22303 MODX Staff
      • 10,725 Posts
      $e->parseProperties()? That is not a method you should be calling manually; if this were true OO, it would be a protected or private method. The properties are extracted into the context of the plugin code, so it would be available like:
      sendResetLog($useremail, $newusername, $newpassword, $fullname);

      But the only properties available to that event are clearly stated in the call to invokeEvent. The only variables that will be available for you to access are:
      $userid
      $username
      $userpassword
      

      Otherwise, you’ll need to hack the call to invokeEvent, and pass the additional data you want to have access to.
        • 31900
        • 3 Posts
        Hi there!

        I was in a super rush to come up with the plugin so i was like stabbing in the dark with all the functions...LOL.

        Anyway, found out how to get that var during the raised event. To get a particular available vars during the raised events, the code is:

        $e = &$modx->Event;
        case "OnWebChangePassword":
            sendResetLog( $e->params["username"], $e->params["userpassword"], $e->params["userid"]);
            break;
        default :
            return; // stop here - this is very important.
            break;
        }
        


        the magic word is:

        $modx->Event->params["xxx"]
        


          • 22303 MODX Staff
          • 10,725 Posts
          They are available there also, but, as I explained, they are extract()’d into the plugin code for you as well, and available directly as:
          $userid
          $username
          $userpassword