We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Rather than rewrite the login snippet code, I think you’d be better off sending all users to the same page. Then put a snippet on that page that gets the user’s page ID and, in your snippet, do this:

    $ page = // (get user's page from the profile here)
    $modx->sendRedirect($modx->makeUrl($page));


    That way you’d be sure the user was logged in and wouldn’t have to worry about the side effects (and potential security issues) of messing with the login code.
      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
      • 25601
      • 14 Posts
      Great - thanks. Got it working smiley

      For the benefit of others that need to achieve the same:

      1. I created a snippet called clientredirect.
      2. In it I put:

      <?php
      $profile = $modx->user->getOne(’Profile’);
      $page = $profile->get(’fax’);
      $modx->sendRedirect($modx->makeUrl($page));
      ?>

      3. I added the resource Id of the client page in the fax box of their profile
      4. I created a resource called clientredirect which runs the snippet - [[!ClientRedirect]]

      Job done. Not as elegant as it could be (I tried getting in the extended field to work but was still getting the get() not working).

      Thanks so much for your help.

      Richard
        • 3749
        • 24,544 Posts
        Glad you got it working. Using the fax field is a great idea (and you can change the caption for it with Form Customization).

        FYI, when you use get() for the extended fields, you get an array back (even if there’s only one extended field) so you have to process it to get an individual element. The real problem is that you have to create the extended field separately for each user, so using the fax field is probably a better choice.
          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
          • 25601
          • 14 Posts
          Thanks. OK - I want to change the Caption using the form customisation just for neatness.

          I’ve set up the rule as attached but it still has the label ’fax’ when I go to update the user’s details. I’m not sure whether I have the action correct and what should go in the containing panel. I looked at the tutorial and it had modx-panel-resource in there but I don’t know what should go there for users.

          I hope I’m close smiley

          Thanks again,

          Richard
            • 3749
            • 24,544 Posts
            Try "modx-panel-user".
              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
              • 25601
              • 14 Posts
              Great - thanks.

              ;D


              Richard