can I have a coupon emailed to a new member and be copied when it occurs?

Ok if someone registers can I have a coupon given to them then or emailed and get a copy at the same time?

  • Roy
    • Design Lord, Child of Thor

    Yes I am trying to make this easy if someone goes to the site with an email and text link I am sending them - this is a new website to my dealers. if they register they get a coupon to print or emailed to them from the webpage and then I get an email or message somehow that they are interested.

  • Ash
    • WordPress Hacker

    Well, would you please try the following code?

    add_action('mp_coupon_use', 'send_me_email');
    function send_me_email($coupon_code) {
      global $current_user;
      get_currentuserinfo();
      $to = "YOUR_EMAIL";
      $sub = "New user is registered with coupon";
      $body = $current_user->user_login . " has been just applied the coupon " . $coupon_code;
      wp_mail($to, $sub, $body);
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hi Roy

    I got updated code from our developer. First you need to add a hook and it can be added to membershipincludes/classes/class.coupon.php between lines 126 and 127.

    do_action( 'membership_coupon_applied', $sub_id, $pricing, $this );

    Then in functions.php or mu-plugins:

    add_action('membership_coupon_applied', 'send_me_email');
    function send_me_email() {
      global $current_user;
      get_currentuserinfo();
      $to = "YOUR_EMAIL";
      $sub = "New user is registered with coupon";
      $body = $current_user->user_login . " has been just applied the coupon ";
      wp_mail($to, $sub, $body);
    }
  • Ash
    • WordPress Hacker

    Hi Roy

    I got updated code from our developer. First you need to add a hook and it can be added to membershipincludes/classes/class.coupon.php between lines 126 and 127.

    do_action( 'membership_coupon_applied', $sub_id, $pricing, $this );

    Then in functions.php or mu-plugins:

    add_action('membership_coupon_applied', 'send_me_email');
    function send_me_email($sub_id, $pricing, $cp) {
      global $current_user;
      get_currentuserinfo();
      $to = "YOUR_EMAIL";
      $sub = "New user is registered with coupon";
      $body = $current_user->user_login . " has been just applied a coupon.";
      wp_mail($to, $sub, $body);
    }

    Let us know if it works.

    Cheers
    Ash

  • Dharmendra
    • The Incredible Code Injector

    Hello Roy,

    I hope you are well today!

    Haven't heard from you for a bit, and wanted to check in here.

    Have you got a chance to try the code as Ashok has suggested?

    Please let us know if you are facing any issues, we're here to help.

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.