We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8425
    • 159 Posts
    Hello,
    I have a list of articles that can only be fully viewed by registered users. Guest users only see the teaser article. When one clicks on "read more" the login screen appears if the user isn’t logged in. I’d like to redirect the user to the document he/she was trying to view upon successful login. I think I need to set the parameter &liHomeId dynamically.
    With WebLoginPE API it looks like one can invoke a plugin when event "OnWebLogin" is triggered. Does anyone know how the plugin should be written?
    Any help is greatly appreciated.
    Thanks
      • 33992 ☆ A M B ☆
      • 455 Posts
      Hi,

      You can use $_REQUEST[’refurl’] to recognize referrer document. create snippet below and name it anything you like (e.g. "refurl"):
      <?php
      return $_REQUEST['refurl'];
      ?>


      and in the redirection page for login, put this snippet call as value of &liHomeId parameter:
      [[WebLoginPE?  . . .  &liHomeId=`[!refurl!]`  . . . ]]


      I didn’t test it but it should work.
      Good luck
        God loves me. 【ツ】


        MODX.ir (Persian Support)

        Boplo.ir/modx/ (Persian)
        • 8425
        • 159 Posts
        Thanks for the reply AHHP but unfortunately it returns an empty string... Does anyone know why?
        Thanks
          • 25551 ☆ A M B ☆
          • 1,231 Posts
          <?php
          // redirect snippet
          $notlogged_location ="unauthorised-access";
          
          if(!isset($_SESSION['webValidated'])){
          header("Location: $notlogged_location");
          }
          ?>


          Create a snippet with the the above code and put [[redirect]] on the pages that you wish that only logged in members can see. If that’s not of any use have you tried Phx?

          [+phx:mo=`registered_member`:then=`full story text`:else=`Please register to read more...`+]
            Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
            AugmentBLU - MODX Partner

            BLUcart - MODX Revolution E-Commerce & Shopping Cart
            • 8425
            • 159 Posts
            Thanks a bunch, perfect!