Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dwanjuki/28346a47a61ad45e3bf4e3218c85d5a8 to your computer and use it in GitHub Desktop.

Select an option

Save dwanjuki/28346a47a61ad45e3bf4e3218c85d5a8 to your computer and use it in GitHub Desktop.
Include User Fields in Check Pending Admin email
<?php
/**
* Include checkout data from pending order as email variables in the Check Pending Admin email.
*
* 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_check_pending_admin_email_data_custom( $data, $email ) {
if ( 'check_pending_admin' === $email->template ) {
$invoice_id = $data['invoice_id'];
$pending_order = new MemberOrder( $invoice_id );
pmpro_pull_checkout_data_from_order( $pending_order );
// Your User Field meta keys.
$meta_keys = array( 'company', 'facebook', 'bio' );
foreach ( $meta_keys as $key ) {
$keydata = isset( $_REQUEST[ $key ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $key ] ) ) : '';
if ( is_array( $keydata ) ) {
$keydata = implode( ', ', $keydata );
}
$data[ $key ] = $keydata;
}
}
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_check_pending_admin_email_data_custom', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment