Anyone know how to get an email from php User class? To reroute Registration E-Mail to getresponse.

Discussion in 'aMember Pro v.4' started by crogue, Dec 24, 2011.

  1. crogue

    crogue New Member

    Joined:
    Dec 17, 2011
    Messages:
    13
    How can you get the user's email stored into a $userEmail variable within the User.php script? I'll bet there's something you can do with those little -> arrows, since google told me they've got something to do with php Classes.

    Here's my situation - maybe yours is similar.

    I use 1shoppingcart to manage money and recurring orders. Since the amember v4 1sc plugin is in beta, the only way for me to do this is to have them create an account in amember, which then takes them to 1sc to complete the transaction.

    But (gasp) some people create the account in amember then don't buy. Tsk, tsk.

    Currently, you can select those people in amember and mass email them, but that's an inefficient solution since emails coming from amember will have a much higher chance of hitting spam filters (that's why aweber and getresponse make the big bucks. They are paid to make sure your emails get delivered).

    So here's my idea: use the User.php sendRegistrationEmail() function (or create one like it) to send an email 'from' the customers address to YOURTEMPCAMPAIGN@getresponse.com.

    This will subscribe them to the campaign (it should be single-optin). then when they complete the payment process you can subscribe them to a BUYERCAMPAIGN@getresponse.com that takes them off of the YOURTEMPCAMPAIGN list. So anyone on the YOURTEMPCAMPAIGN list is someone who abandoned their cart. You know they're interested, and can give them special offers, etc.

    in v3 there was that awesome kencinnus plugin http://plugins.kencinnus.com/plugin/amail/ that did this - but hes not offering support for it anymore. Sigh.

    Anyway, here's how I think something like this can be written:

    The User.php has this function:

    PHP:
        function sendRegistrationEmail()
        {
            if (
    $et Am_Mail_Template::load('registration_mail'$this->lang))
            {
                
    $et->setUser($this);
                
    $et->password $this->getPlaintextPass();
                
    $et->send($this);
            }
        }
    Perhaps some lines can be added to this function that sends the email to getresponse (or your autoresponder of choice)? It already has the user's email in there somewhere. And it's a function that is called when they sign up for amember, before they complete payment.

    I know I'm not the only person with this problem - but my knowledge of php classes is too limited for me to write this myself. I'm OK with adding some lines to the amember code - meaning that every update I'll have to add them again. It's a work-around until someone writes a bonafide plugin. Which will probably be a long while.

    if someone can just show me how to get the user's email stored into a $userEmail variable, I think know enough php to send it to some sendASimpleEmail() function somewhere. I'll bet there's something you can do with those little -> arrows, since google told me they've got something to do with php Classes.
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    We are working to develop full-featured solutions for aWeber and similar services.

    Right now, as quick soltion, you may use www.sendgrid.com - they provide an SMTP server that you can configure at aMember Cp -> Setup -> E-Mail to make sure your messages are delivered.
  3. crogue

    crogue New Member

    Joined:
    Dec 17, 2011
    Messages:
    13
    Figured it out! This will work until that full-featured solution is implemented (Thanks for the heads up, Alex!)

    If you want to put a customer in your getresponse campaign:

    The follwing code replaces the sendRegistrationEmail() function in amember/application/default/models/User.php

    What it does is put customers on a getresponse list when they start the signup process. I have 1shoppingcart put them on a 'customers' list when they complete checkout, and it takes them off of this 'pending' list. Be sure to enable 'Send Registraion Email' in amember cp -> settings -> Email.

    (I had to contact the getresponse devteam to get them to allow single-optin for my 'pending' list. Normally API contact adds are always double-optin)

    If you just want them put in a getresponse campaign after they signup, you could probably just put this code inside of the sendSignupEmail() function instead of the sendRegistrationEmail() one.

    PHP:
        function sendRegistrationEmail()
        {
            if (
    $et Am_Mail_Template::load('registration_mail'$this->lang))
            {
                
    $et->setUser($this);
                
    $et->password $this->getPlaintextPass();

    //@@@ subscribe the customers to the 'pending' getresponse list, complete with the following custom fields:
    $name $this->getName();
    $email $this->getEmail();
    $username $this->login;
    $password $this->getPlaintextPass();
    $memberid $this->user_id;
    include 
    'getresponse.php';

    //@@@ Send an email so we know that someone started the signup process.
    //This isn't necessary, but I like it just because I can keep tabs on how many people
    //start checkout. Feel free to leave these lines out.
    $to      'my@email';
    $subject $name ' signed up in amember';
    $message ='Name: ' $name "\r\n" .
    'Email: ' $email "\r\n" .
    'username: ' $username "\r\n" .
    'password: ' $password "\r\n";
    $headers 'From: ' $email "\r\n" .
        
    'Reply-To: ' $email "\r\n" .
        
    'X-Mailer: PHP/' phpversion();
    mail($to$subject$message$headers);

    //@@@ uncomment the following line to have the customer get the amember registration email.

               // $et->send($this);
            
    }
        }
    To create the 'getresponse.php' file, I just copy/pasted from the folloiwng page with a little modification:
    https://github.com/GetResponse/DevZone/blob/master/API/examples/php_synopsis.php

    Also, I should point out that everywhere I change amember code I put a '@@@' in a comment. That way when I upgrade amember (and it overwrites my changes) I can search my local files for '@@@' and know that I need to re-introduce those changes.

    Let me know if you have any questions. This works all fancy-like. Plus getresponse now has their username and password in a custom field, so I can remind them of those things in emails.
  4. crogue

    crogue New Member

    Joined:
    Dec 17, 2011
    Messages:
    13
    Also, if you don't get permission to do single-optin on your getresponse campaign, you can change
    PHP:
    $to      ='my@email';
    to
    PHP:
    $to      ='CAMPAIGN@getresponse.com, my@email';
    Not as elegant of a solution, since this doesn't pass the user's name, username, password, or amember ID to getresponse. But you can go into getresponse and uncheck 'send confirmation email' in the campaign settings for signups by email.
    alex likes this.
  5. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Cool solution! Thank you for sharing!
  6. trafficbrowser

    trafficbrowser Member

    Joined:
    Oct 30, 2011
    Messages:
    46
    I am looking forward to the aweber integration. :)

Share This Page