Skip to content

Instantly share code, notes, and snippets.

@MaryOJob
Forked from gausam/mycustom_confirmation.html
Created August 30, 2021 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryOJob/4e3bb2f3f3733a7ecbea3f7771585e8a to your computer and use it in GitHub Desktop.
Save MaryOJob/4e3bb2f3f3733a7ecbea3f7771585e8a to your computer and use it in GitHub Desktop.
Send additional custom confirmation email
<h3>Lorem Isupm, !!display_name!!</h3>
<p>Any content can be added here.</p>
<p>Please see the <i>Variable Reference</i> at https://www.paidmembershipspro.com/add-ons/email-templates-admin-editor/</p>
<p>Account: !!display_name!! (!!user_email!!)</p>
<p>Log in to your membership account here: !!login_link!!</p>
<?php
/**
* This recipe sends an addition custom confirmation email
*
* The email template integrates with the Email Templates Admin Editor Add On:
* https://www.paidmembershipspro.com/add-ons/email-templates-admin-editor/
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
* Integrate with Email Templates Admin Editor
* @param String[] $templates Templates
* @return String[]
*/
function mypmpro_email_templates( $templates ) {
$templates['mycustom_confirmation_email'] = array(
'subject' => 'Subject for custom', // Enter your custom email subject here
'description' => 'Additional Custom Confirmation Email',
'body' => file_get_contents( dirname( __FILE__ ) . "/mycustom_confirmation.html" ),
);
return $templates;
}
add_filter( 'pmproet_templates', 'mypmpro_email_templates', 10, 1 );
/**
* Register template path in PMPro
*/
function mypmpro_add_email_template( $templates, $page_name, $type = 'emails', $where = 'local', $ext = 'html' ) {
$templates[] = dirname( __FILE__ ) . "/mycustom_confirmation.html";
return $templates;
}
add_filter( 'pmpro_email_custom_template_path', 'mypmpro_add_email_template', 10, 5 );
/**
* Sends the custom confirmation email after a user checks out
* @param int $user_id New user's ID
* @param object $morder Order
* @return void
*/
function send_custom_email_pmpro_after_checkout($user_id, $morder )
{
$user = get_userdata($user_id);
$pmpro_email = new PMProEmail();
$pmpro_email->subject = 'Subject for custom'; // Enter custom email subject here
$pmpro_email->email = $user->user_email;
$pmpro_email->data = array(
"display_name" => $user->display_name,
"user_login" => $user->user_login,
"user_email" => $user->user_email,
"sitename" => get_option( "blogname" ),
"siteemail" => pmpro_getOption( "from_email" ),
"login_link" => wp_login_url(),
);
$pmpro_email->template = 'mycustom_confirmation_email';
add_filter( 'pmpro_email_body_footer', '__return_false', 99 );
$pmpro_email->sendEmail();
remove_filter( 'pmpro_email_body_footer', '__return_false', 99 );
}
add_action('pmpro_after_checkout', 'send_custom_email_pmpro_after_checkout', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment