We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    Hi all,

    I’m working on a members only site, and would like to change the default settings for new documents to be available to Registered rather than Public.

    anyone knows how to cook it and mind sharing with me?
      • 7231
      • 4,205 Posts
      You can use a plugin to do this. I have done this before but dont have the ready code on hand (I will look for it later). But in any case I adapted the inherit template plugin and added a condition to set the document group on creting new documents under a certain parent.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 27330
        • 884 Posts
        I thought plugin is the way to go. You helped me few months back when I wanted to keep the "Continue Editing" button pressed when creating new docs.

        This was the plugin code back then
        /*
        *  keep the "Continue editing" checked by default, can be useful with new 
        *  site where lots of 'save' clicks happens
        *  Check all the events you wish  to apply it for.
        *  clean code :) by dev_cw  
        *  http://modxcms.com/forums/index.php?topic=23532.msg146622#msg146622
        *
        */
        $_GET['stay'] = "2"; 
        $_REQUEST['stay'] = "2";




        Problem is, how do I find what triggers the document permission?
        I assume most if not all new document defaults are controllable via plugins, if you can teach me how to fish it, I’ll love to write the article in the wiki for future users. I honestly expected it to be in the configuration options, sorta like the Default tpl to use on new docs you know what I mean?
          • 7231
          • 4,205 Posts
          For the document group you can set it in the same principal however the value is an arrays so the syntax would be a little different:
          $_POST['user_groups'] = array(1);
          Where 1 is the ID of the document group you want to set.

          To fish out this data look at the source code of the mutate_content.dynamic.php document in the manager>actions folder. The key is to set the plugin event to the correct event for what you want to get accomplished.

          You could add action check (like in the inherit template plugin) to make an action only happen during certain conditions (editing a document under parent x).
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 27330
            • 884 Posts
            thanks Shane for the fast reply,

            Is this suppose to work with this single line only?
            I tried and it doesn’t give me any error just isn’t changing anything. I assume the event I want to use is onDocPrerender.

            when I tried it with $_GET & $_REQUEST it gave me phrase error.
              • 7231
              • 4,205 Posts
              I gave you bad code. The correct (tested and all) code is:
              $_POST['docgroups'] = array('2');
              where 2 is the id of the document group.

              You need to check the OnDocFormPrerender event on this one.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don't know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 4310
                • 2,310 Posts
                Thanks dev_cw.
                That’s a handy little plugin when creating a "private" site.
                  • 7231
                  • 4,205 Posts
                  I am not sure but ManagerManager might have this feature built in as well.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don't know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 4310
                    • 2,310 Posts
                    Yeh, I keep meaning to look into ManagerManager but the thread is so long now, and it looks fairly complex.
                    One day when I have some time to spare!