We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36562
    • 94 Posts
    What i am doing:
    Each time a visitor submits a contactform, i create a new resource using runProcessor('resource/create') storing the contact form data as a resource.

    Issue:
    The resource is only saved if i am logged into the manager while submitting the form. I am guessing there are a couple of ways to sort this. Just going the route of $modx->newObject('modDocument') works, but what would be the recommended way?

    This question has been answered by BobRay. See the first response.

      --------------------------------------
      www.williamastrom.se
    • discuss.answer
      • 3749
      • 24,544 Posts
      Allowing every person on the planet with internet access to create new resources on your site is kind of asking for trouble. wink Imagine that a bot fills in and submits your contact form a few thousand times.

      Can you explain why you want to do that? Maybe there's another way.

      Calling the 'resource/create' processor requires that the user have at least new_document permission (and publish_document if the doc is published). In either case, they have to be logged in.

      If you really want to do it, though, $modx->newObject() is really the best way, though you're going to want to sanitize the crap out of the user's input before letting it get anywhere near MODX or the database.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36562
        • 94 Posts
        Thank you Bob.

        I want to do it simply to make sure i save all contact form submissions without relying on emails. I guess i could just create a separate table instead.

        And of course i would take care of the security issues this could potentially cause.

        Thanks, a lot for the answer i was basically looking to understand if there was a way of using runProcessor. But i guess ill just create a separate table instead.
          --------------------------------------
          www.williamastrom.se
          • 3749
          • 24,544 Posts
          I think writing them to a file, or a series of files, might be safer and would cut down potential stress on the database.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting