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

    I am building a site in Revo, and I have a product page where if the user is logged in I want them to be able to see the spec sheet for the product, else see and message about logging in.
    I have followed the ’login’ tut (http://rtfm.modx.com/display/ADDON/Login) and have managed to create a members only page, but can you have it build into a template?

    something like:

    [[if logged in `dothis` else `dothis`]]

    Any help here welcome...
      Linux, PHP 5.2, MySQL 5.0, Revo 2.2.0-pl2
      • 3749
      • 24,544 Posts
      The Personalize snippet will show one chunk to logged-in users and another chunk to the rest.

      If you want to redirect users to another page, I think you’d need a custom snippet. Something like this:

      <?php
      $redirectPage = 12 //ID of the page you want to send not-logged-in users to
      
      if ($modx->user->hasSessionContext('web')) {
         return "";  // do nothing if the user is logged in
      } else {
         $modx->sendRedirect($modx->makeUrl($redirectPage));
      }
      
        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