We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19023
    • 12 Posts
    I am modifying a MODx 1.0 plugin (QM+ 1.5) and need to get access to the $_POST superglobal before the [+Placeholder+] get replaced.

    If I stash the $_POST variable immediately in index.php (global $stash; $stash=$_POST;). I get the result I want that way. I don’t want to leave a hack like this in the index.php file. If I need to use it, I’d much rather have a event-triggered plugin. Frustratingly though, I’ve tried stashing it at most all WebPage event points and it does not seem to catch the value in time, before the placeholder replacement.


    I’ve consulted the http://wiki.modxcms.com/index.php/Order_of_execution but am having trouble tracking down how or why the $_POST variable contents ever gets replaced.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      A plugin using OnWebPageInit will be triggered before anything happens as far as parsing or even loading the requested resource from cache or database, so any POST values will be available..
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 19023
        • 12 Posts
        That is what I expected, but no luck. $_POST at the head of index.php != $_POST at OnWebPageInit (for [tvsomething] => [+something+]).

        Maybe it is possible that the code (global $grab; $grab = $_POST;) works differently in a plugin context vs. inline?