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

    I am using Revo 2.2.2pl and setting up a paid subscription set up with the cart 'Foxycart'. Foxycart send a xml post when someone pays for a subscription. You then grab this xml post validate with a key and then have all of their details to add as a new user.

    Now once I have their details I can add a new user as described by Bob here - ( https://forums.modx.com/thread/31469/creating-a-new-web-user-with-the-api ) . But that would obviously just add them to the users table and then they could just log in.

    What I would like to do is force them through the same process of the Login plugin 'Request Membership' feature which sends them an email with a hashed link in they then have to click it and it confirms their account. Described here ( http://rtfm.modx.com/display/ADDON/Login.Request+Membership )

    Does anyone have any suggestions as to how to achieve this?

    Once I have the new users details I could try and spoof a post to a page with the register plugin on but that just seem messy. Is there a clean way of easily utilizing / replicating the functionality of the email verification feature of Login? Programaticcally calling the snippet with all of the variables as parameters doesn't sound like it would work but hopefully you get my idea.

    Thanks in advance. [ed. note: megasteve4 last edited this post 14 years ago.]
      • 3749
      • 24,544 Posts
      If you're already in Php and you have the user data, the most efficient thing would be to grab a Tpl chunk and send an email to the user with a link to a page containing the ConfirmRegister snippet.

      Installing the Subscribe extra would actually create most of that for you. There are parts of it you wouldn't be using, but it will create all the stuff for handling registration with email confirmation, and I think you could borrow its code to email the user and put it in your snippet.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 37044
        • 68 Posts
        Thanks Bob.

        So just to clarify what you are suggesting. (Note I already have the Login addon installed for my 'free' users)


        If I have interpreted you correctly then the only bit I have issues with is encoding the link to send to the user for activation.

        The link format is http://www.mydomain.co.uk/registration-confirmation/?lp=OTIwcHQzYjg%253D&lu=Ym9idGVzdA%253D%253D

        lp = pword / lu = username

        I cant for the life of my find the bit of code in the Login addon that creates the link - I think the vars are base 64 encoded but am a little unsure.

        Any suggestions where the piece of code is that builds this link? Or how it might be encoded?

        Once again thanks for your help.
          • 3749
          • 24,544 Posts
          Yes, trying to find specific code in the Login package can make your hair fall out. wink

          That code is in the register.php processor (in core/components/login/processors/), but I think you can just use something like this instead and let the Register snippet handle everything:

          $properties = array(
              // I'm guessing at these six:
              'usernameField' = 'username',
              'username' = $userName,
              'passwordField' = 'password',
              'password' = $password,
              'emailField' = 'email',
              'email' = $email;
          
          
              'submitVar' = 'login-register-btn',
              'activationResourceId' = '12',  // ID of the page with the ConfirmRegister snippet
              'submittedResourceId' = '13', // ID of your "Thanks for Registering" page
              'activationttl' = `480`, // Number of minutes until activation email expires
              'usergroups' = 'Subscribers:Subscriber', // (optional) usergroup:role
              'useExtended' = '0',  // unless you have extended fields set
              'activationEmailTpl' = 'ActivationEmailTpl', // name of activation email Tpl chunk
              'activationEmailSubject' = 'Please activate your account at yoursitename.com ',
          );
          
          $modx->runSnippet('Register', $properties);



          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html

          [ed. note: BobRay last edited this post 14 years ago.]
            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
            • 37044
            • 68 Posts
            Hi Thanks again Bob. I was thinking along those lines but when you see the code all becomes clear!!

            Hopefully the above should be enough to get me up an running. I will post back if I find anything interesting.