Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created December 12, 2024 13:52
Show Gist options
  • Save ipokkel/627f12e0280e6bbf192c1e87d4e69182 to your computer and use it in GitHub Desktop.
Save ipokkel/627f12e0280e6bbf192c1e87d4e69182 to your computer and use it in GitHub Desktop.
<?php
/**
* Add membership officer to email data
*
* 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_email_data_membership_officer( $data, $email ) {
$args = array(
'role' => 'imc_membership_officer',
'orderby' => 'user_nicename',
'order' => 'ASC',
);
$users = get_users( $args );
$first_user = reset( $users );
$display_name = $first_user->display_name;
$data['membership_officer'] = $display_name;
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_email_data_membership_officer', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment