We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26975
    • 26 Posts
    I’ve got a bunch of pages that have registered user content only. On most, I’m using @binding in a template variable to show an information request form. This is fine when registered users view the page, but when unregistered, I want to swap out the info form for a registration form. My thought process is that it would be simplest to just change the @DOCUMENT, like so:

    <?php
    
    $private = $modx->documentObject['registeredUserContent'];
    $loggedIn = $modx->isMemberOfWebGroup('Registered Users','Site Admins');
    $normalContent = $modx->documentObject['content'];
    $formBeingAdded = $modx->documentObject['formAddition'][1];
    
    if(if($private[1]!=""){
    	if("" == $normalContent && !$loggedIn && "" != $formBeingAdded){
    		$formBeingAdded = "@DOCUMENT 47"; // show a registration form instead of an info request form
    	}
    }
    ?>
    


    I tried this in a snippet and while it would say that the key was changing to 47, the form wouldn’t. Now I’m trying it in a plugin, but it still doesn’t seem to be working. Is there a way to get this to work, or am I just missing something?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Maybe a caching issue? The page is cached with one form, and since it’s cached, it’s going to show that form every time the page is loaded. Try uncaching the page and see if that’s the problem.
        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
        • 26975
        • 26 Posts
        I turned caching off and I’m still not getting the form. Will a snippet be called early enough to affect the template variables, or do I need to use a plugin? And what event should the plugin be set for?
          • 26975
          • 26 Posts
          Does anyone have experience with this?