Skip to content

Instantly share code, notes, and snippets.

@MaryOJob
Last active December 5, 2024 14:40
Show Gist options
  • Select an option

  • Save MaryOJob/db19e2a60f9c4bdbaedefca1b4af909f to your computer and use it in GitHub Desktop.

Select an option

Save MaryOJob/db19e2a60f9c4bdbaedefca1b4af909f to your computer and use it in GitHub Desktop.
Change the email address for admin-related emails in Paid Memberships Pro for different levels
<?php // do not copy this line
/**
* Change the email address for admin-related emails in Paid Memberships Pro for different levels.
* Follow this guide to add custom code to your WordPress site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_admin_to_email( $user_email, $email ) {
// Check the email template for different levels
if ( strpos( $email->template, "_admin" ) !== false ) {
// Change email address based on membership level
switch ( $email->data['membership_id'] ) {
case 1:
$user_email = '[email protected]';
break;
case 2:
$user_email = '[email protected]';
break;
case 3:
$user_email = '[email protected]';
break;
case 4:
$user_email = '[email protected]';
break;
// Add more cases as needed for other levels
// ...
default:
// Use a default email address for any other level
$user_email = '[email protected]';
break;
}
}
return $user_email;
}
add_filter( "pmpro_email_recipient", "my_pmpro_change_admin_to_email", 10, 2 );
@MaryOJob
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment