Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dwanjuki/540a57a0596f4596cf3d3c5f2691d88b to your computer and use it in GitHub Desktop.
Save dwanjuki/540a57a0596f4596cf3d3c5f2691d88b to your computer and use it in GitHub Desktop.
Send admin an email notification on Pay By Check pending order creation
<?php
/**
* Send admin an email notification on Pay By Check pending order creation
*
* 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/
*/
function my_pmpro_pbc_order_added_admin_email( $morder ) {
if ( 'check' !== strtolower( $morder->gateway ) ) {
return;
}
$level = $morder->getMembershipLevel();
$user = get_userdata( $morder->user_id );
$to = get_bloginfo( 'admin_email' );
$subject = 'New pending PBC order for ' . $user->display_name;
$body = '<p>Account: ' . $user->display_name . ' (' . $user->user_email . ')</p>';
$body .= '<p>Membership Level: ' . $level->name . '</p>';
$body .= '<p>Invoice #: ' . $morder->code . '</p>';
wp_mail( $to, $subject, $body );
}
add_action( 'pmpro_added_order', 'my_pmpro_pbc_order_added_admin_email' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment