Skip to content

Instantly share code, notes, and snippets.

@dwanjuki
Forked from andrewlimaza/send_custom_email.php
Last active February 2, 2023 13:13
Show Gist options
  • Save dwanjuki/1cf990b7dd23f7ac742eef369dc785fc to your computer and use it in GitHub Desktop.
Save dwanjuki/1cf990b7dd23f7ac742eef369dc785fc to your computer and use it in GitHub Desktop.
Send a custom email to user after the user's email is validated
<?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
*/
function my_send_email_after_validation( $user_id ){
$user_details = get_userdata( $user_id ); //get validated user's data
$my_email = new PMProEmail();
$my_email->email = $user_details->user_email; // send to the validated email address
$my_email->subject = 'Thank you for validating your email address!'; // Set email subject line here
$my_email->template = 'My Post Validation Email'; // custom name of email template.
$my_email->body = '<p>Hi there,</p>'; // header of body content goes here
$my_email->body .= '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>'; // body content goes here.
$my_email->body .= '<p>Best Regards,</p> My Site Name.'; // footer content goes here.
$my_email->sendEmail();
}
add_action( 'pmproec_after_validate_user', 'my_send_email_after_validation', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment