Plain Text Password on Signup

Discussion in 'aMember Pro v.4' started by scottlott, Jul 9, 2013.

  1. scottlott

    scottlott Member

    Joined:
    Jun 17, 2010
    Messages:
    50
    I'm trying to display my user's password in receipt e-mails.

    I found this page that got me halfway there:
    http://www.amember.com/docs/How_to_store_plain_text_passwords_for_users

    So the users password can be displayed only after they've changed it to something else. If it's their original password, there is no way for this to work.

    How can I set this up so that users plain text passwords are created in one of two situations:
    A) User creation/signup <- probably the most secure, if I can at least get this that would be great
    B) Automatically for all users <- most ideal situation, if user already has account in the system I don't want the password sent to them to be blank.
  2. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    Go to Setup/Configuration -> E-mail and disable "Send Signup E-mail" email and enable "Send Registration E-Mail" instead, as that one has user's password in plain text.
  3. scottlott

    scottlott Member

    Joined:
    Jun 17, 2010
    Messages:
    50
    That almost does what I want.

    I found a solution, the article I linked to suggested this:
    PHP:
    <?php
     
    Am_Di
    ::getInstance()->hook->add(Am_Event::SET_PASSWORD'savePlainTextPassword');
     
    function 
    savePlainTextPassword(Am_Event_SetPassword $event){
        
    $pass $event->getPassword();
        
    $user $event->getUser();
        if(
    $pass){
            
    $user->updateQuick('plain_password'$pass);
        }
    }
    Adding a line to the top drops a hook into the login process, allowing you to generate the plain text password upon login.

    PHP:
    <?php
     
    Am_Di
    ::getInstance()->hook->add(Am_Event::SET_PASSWORD'savePlainTextPassword');
    Am_Di::getInstance()->hook->add(Am_Event::AUTH_AFTER_LOGIN'savePlainTextPassword');
     
    function 
    savePlainTextPassword(Am_Event_SetPassword $event){
        
    $pass $event->getPassword();
        
    $user $event->getUser();
        if(
    $pass){
            
    $user->updateQuick('plain_password'$pass);
        }
    }
    This allows access to the plain text password for e-mailing, including it on the thanks page, etc.

Share This Page