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

    I built a plugin which is running onDocFormSave event. When saving a resource, it creates a new context with some context settings (e.g. site_url and http_host), access policies and a resource in this context (a symlink). This symlink contains the resource I am saving and is used to show my content on a different domain.

    When saving my resource as an administrator, everything works fine. I can see my resource content on the domain.
    When saving it with a different user role, the context and symlinks are created as well, but the domain is showing the error page when I browse it. I then have to save the symlink and context manually again, then I can see the content on the domain.

    Since everything gets created properly, I think that the problem might be related with the following code. Is it possible that this is only working when executed from a plugin which is triggered from an admin user? I already tried to give the other user roles empty_cache permission, but without success.

    I am using Xrouting for routing the domains.

       
    $modx->cacheManager->refresh(array(
            'auto_publish' => array('contexts' => $contexts),
            'context_settings' => array('contexts' => $contexts),
            'resource' => array('contexts' => $contexts),
            ));



      • 5430
      • 247 Posts
      Did you give your other user roles empty_cache permissions on ALL contexts? I ran into a context cache problem a while ago that ended up requiring every user group with manager access to have permissions to clear the cache on ALL contexts in that MODX instance otherwise it would cause domain routing to fail altogether if they attempted to clear the cache with context-limited access.
        • 3749
        • 24,544 Posts
        The problem may be with setting the $contexts variable. If you use xPDO to get the possible contexts, it won't show contexts the current user doesn't have a Context Access ACL policy for. If you use PDO to get the context list, it will bypass the permission system and give you all of them.

          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