Created
October 12, 2022 19:04
-
-
Save ideadude/89d4ab2d9944b8b86aec4b3008598dc3 to your computer and use it in GitHub Desktop.
Add user_id as a data variable for email templates in PMPro
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 | |
/* This code will add user_id as a data variable for email templates in PMPro. | |
* | |
* 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/ | |
*/ | |
// begin copying code below here | |
function my_pmpro_email_custom_data($data, $email) { | |
if( ! empty( $data['user_login'] ) ) { | |
$user = get_user_by( "login", $data['user_login'] ); | |
$data['user_id'] = $user->ID; | |
} | |
return $data; | |
} | |
add_filter( "pmpro_email_data", "my_pmpro_email_custom_data", 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment