Created
November 4, 2025 09:34
-
-
Save dwanjuki/28346a47a61ad45e3bf4e3218c85d5a8 to your computer and use it in GitHub Desktop.
Include User Fields in Check Pending Admin email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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