We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48507
    • 7 Posts
    Give me the full snippet using which if i visit the page it asks for password.After giving the password it show the page.
      • 48507
      • 7 Posts
      [b]I have put this in a chunk naMED PrivatePage[/b]

      <?php
      /* PrivatePage snippet */
      /* Redirect users who shouldn't see this page */

      /** @param $redirectTo string -- (optional) ID of page to redirect to;
      * default: unauthorized page
      * @param $userGroups string -- (optional) Comma-separated list of
      * User Groups that are authorized;
      * if not set, users who are not logged in are redirected
      * */

      $output = '';

      function forward($id, &$modx) {

      if (empty($id)) {
      $modx->sendUnauthorizedPage();
      }
      $url = $modx->makeUrl((integer) $id, "", "", "full");
      if (empty($url)) {
      die('MakeUrl failed. ID: ' . $id);
      }
      $modx->sendRedirect($url);
      }

      $redirectTo = $modx->getOption('redirectTo', $scriptProperties, '');
      $userGroups = $modx->getOption('userGroups', $scriptProperties, '');

      if ((!empty($userGroups)) && strpos($userGroups, ',') !== false) {
      $userGroups = explode(',', $userGroups);
      }

      if (empty($userGroups)) {
      /* Redirect anyone who is not logged in */
      $key = $modx->context->get('key');
      if (!$modx->user->hasSessionContext($key)) {
      forward($redirectTo, $modx);
      }
      } else {
      /* redirect if not a member of specified group(s) */
      if (!$modx->user->isMember($userGroups)) {
      forward($redirectTo, $modx);
      }
      }

      return $output;
      ?>




      After saving this put the snippet on the page
      [[!PrivatePage]]


      Didnt work


      Also used this
      [[!PrivatePage? &userGroups=`Subscribers,Administrator` &redirectTo=`12`]]
      But no helped
        • 3749
        • 24,544 Posts
        @coding31: Your posts are off topic for this thread, which is about the inability to save resources.

        Please start a new thread.
          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
          • 12410
          • 353 Posts
          @coding31 - Please and thank you and similar phrases may work better for you. Lmao