Auto email to publisher on signup

Discussion in 'Customization & add-ons' started by twholycross, Feb 8, 2011.

  1. twholycross

    twholycross aMember Pro Customer

    Joined:
    Jan 30, 2007
    Messages:
    63
    I would like to have an auto email sent to a publishers email address upon completed subscription so they can ship the students books. Is there a way that I can use the Products/customized signup email function and smarty to send this email with the necessary amember data to the publisher's address along with the students? Or better yet a unique email to the publisher with unique data upon completed subscription?

    appreciate the help.

    TW
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Sure you can do this from finish_waiting_payment hook . here is example:
    http://manual.amember.com/Using_site.inc.php_and_hooks
    PHP:
    setup_plugin_hook("finish_waiting_payment""fwp");
    function 
    fwp($payment_id){
    $payment $db->get_payment($payment_id); 
    mail_customer("email@address.com""product $payment[product_id] was purchased by user $payment[member_id]""new order"); 
    }
  3. twholycross

    twholycross aMember Pro Customer

    Joined:
    Jan 30, 2007
    Messages:
    63
    Thanks so much Alexander. I appreciate Amember and the work you guys do in supporting it.

    TW
  4. twholycross

    twholycross aMember Pro Customer

    Joined:
    Jan 30, 2007
    Messages:
    63
    So I got most of this working. I am having problems getting the phone field to show up in the email though. I am using $member['data']['phone'] as the phone field is common and within the data string, but it will not show up.

    in case somebody else wants to use the code (that works). Here it is with the addition of a line that will check to see that they ordered the appropriate product:

    Can somebody tell me why the phone number is not printing?

    Code:
    <?php
    
    // Customized code goes below this line
    
    setup_plugin_hook("finish_waiting_payment", "fwp");
    function fwp($payment_id){
    global $db;
    $payment = $db->get_payment($payment_id); // $payment is now an array
    if ($payment['product_id'] != 1 && $payment['product_id'] != 3 && $payment['product_id'] != 5) return;
    $product = $db->get_product($payment['product_id']);
    $member = $db->get_user($payment['member_id']);
    mail_customer("email@domain.com, email@domain2.com", "Hello \n\n Please ship the agreed upon text/s for the the course listed below.  \n\n$product[title]  \n$member[name_f] $member[name_l].\nAddress: $member[street], \n$member[city], \n$member[state] $member[zip], \n$member[country] \n\nStudent Phone: $member['data']['phone']", " New Order");
    
    }
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    One thing that I can see from your code.
    $member['data']['phone'] will not be parsed correctly if you will use it within string.
    So try to use:
    PHP:
    mail_customer("email@domain.com, email@domain2.com""Hello \n\n Please ship the agreed upon text/s for the the course listed below.  \n\n$product[title]  \n$member[name_f] $member[name_l].\nAddress: $member[street], \n$member[city], \n$member[state] $member[zip], \n$member[country] \n\nStudent Phone: ".$member['data']['phone'], " New Order");
    instead of
    PHP:
    mail_customer("email@domain.com, email@domain2.com""Hello \n\n Please ship the agreed upon text/s for the the course listed below.  \n\n$product[title]  \n$member[name_f] $member[name_l].\nAddress: $member[street], \n$member[city], \n$member[state] $member[zip], \n$member[country] \n\nStudent Phone: $member['data']['phone']"" New Order");
  6. twholycross

    twholycross aMember Pro Customer

    Joined:
    Jan 30, 2007
    Messages:
    63
    Perfect, thanks again Alexander.

    TW

Share This Page