Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmasterninjay/ae50d5f7d860d7d7638da26afb3ef523 to your computer and use it in GitHub Desktop.
Save webmasterninjay/ae50d5f7d860d7d7638da26afb3ef523 to your computer and use it in GitHub Desktop.
Send a custom email when a user checks out for a pmpro level.
<?php
/**
* Add this code to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This function below sends a custom HTML email to the user that checks out for a pmpro membership level, easily extendible to send to admins, or specific users and so on.
* Website: https://paidmembershipspro.com
*/
//let's send a custom email after user checkouts. This will not send an email if an admin changes user's level inside member area.
function custom_email_after_checkout( $user_id, $morder ){
$user_details = get_userdata( $user_id ); //get user data for user checking out.
$my_email = new PMProEmail();
$my_email->email = $user_details->user_email; //who to send the email to - send to user that is checking out.
$my_email->subject = 'This is a custom subject header'; //change this to the header you would like to use.
$my_email->template = 'My Custom Email'; //custom name of email template.
$my_email->body = '<p>Hi there,</p>'; //header of body content goes here
$my_email->body .= '<p>Thank you for your purchase. {Change this text} </p>'; //body content goes here.
$my_email->body .= '<p>Best Regards,</p> My Site Name.'; //footer content goes here.
$my_email->sendEmail();
}
add_action( 'pmpro_after_checkout', 'custom_email_after_checkout' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment