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

    Some pages of my website i want to be only accessible for authorized members. So i created a document group and user group.

    But when a visitor comes to my site, he doesn’t see the "protected" pages until he registers and login.

    I want to show also the protected pages in the menu when a visitor isn’t logged in, so I can use the "Unauthorized page:"-setting in my MODx configuration.

    I am using WayFinder to build my menu...

    Somebody can tell me how I can do this?

    Thanks in advance!
    Gust
      • 4775
      • 47 Posts
      I’m looking for this answer as well for the same reasons above.
        • 7231
        • 4,205 Posts
        You need to edit the query in the Wayfinder code. This has been discussed before in the forum but I could not find the solution. In any case the code to edit is:

         // get document groups for current user
        	        if($docgrp = $modx->getUserDocGroups()) $docgrp = implode(",",$docgrp);
        	        // build query
        	        $access = ($modx->isFrontend() ? "sc.privateweb=0" : "1='{$_SESSION['mgrRole']}' OR sc.privatemgr=0").(!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})");
        			$sql = "SELECT DISTINCT {$fields} FROM {$tblsc} sc LEFT JOIN {$tbldg} dg ON dg.document = sc.id WHERE sc.published=1 AND sc.deleted=0 AND ({$access}){$menuWhere} AND sc.id IN (".implode(',',$ids).") GROUP BY sc.id ORDER BY {$sort} {$this->_config['sortOrder']} {$sqlLimit};";

        I think that if you remove the ".(!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})" will resolve this but I am not sure.

        Be sure to back up the original wf code just in case it does not work grin
          [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]