We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37059
    • 368 Posts
    This is not your typical login situation. I am using Visioncart, which requires Login to create users before they are allowed to check out. I need the customer to be able to create a password and become a non-privileged webuser with as little fuss & muss as possible, so he can get back to placing his order smiley I have already turned off activation emails to auto-approve registrations. Now I would like to automatically log the user in once he is registered, which will eliminate another step from the process. Is there a way to do this with Login? Any help would be greatly appreciated.
      Jason
      • 37059
      • 368 Posts
      Okay, I got it working.

      Disclaimer: I am a PHP developer of the JETBD variety (Just Enough To Be Dangerous), so the following "solution" may be insecure/incompatible/stupid/redundant or any number of other things. If somebody with greater development chops would like to comment, I’d be most grateful.

      My solution was to create a snippet and call it as a postHook on Register. Here is the snippet I created, which I called ’postRegister’:

      $c = array(
                          'login_context' => 'web',
                          'username' => $_POST['email'],
                          'password' => $_POST['password']
                      );
                      $response = $modx->runProcessor('security/login',$c);
      


      And the call:

      [[!Register?
          &submitVar=`registerbtn`
          &activation=`0`
          &usernameField=`email`
          &validate=`
          	nospam:blank,
          	password:required:minLength=^6^,
          	password_confirm:password_confirm=^password^,
          	email:required:email`
          &placeholderPrefix=`reg.`
          &usergroups=`1`
          &postHooks=`postRegister`
          &submittedResourceId=`10`
          &persistParams=`1`
      ]]
      


      Without &persistParams, the contents of my Visioncart shopping cart got discarded.

      Once again, experienced MODxers please feel free to issue baloney alerts if appropriate. wink
        Jason
        • 23196
        • 14 Posts
        Dear Mr plrbear,

        very nice post it pointed me in the right direction

        many thanks!!!