Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created March 19, 2018 15:50
Show Gist options
  • Save pbrocks/15f9bf47280cb39dc655cb133486b7ea to your computer and use it in GitHub Desktop.
Save pbrocks/15f9bf47280cb39dc655cb133486b7ea to your computer and use it in GitHub Desktop.
This filter function creates a variable from Usermeta to be used with PMPro emails.
/**
* This filter function creates a variable from Usermeta to be used with PMPro emails.
*
* The function returns a variable prepared for the special html syntax within PMPro emails. In this example, the value of the array key 'favorite_color' is returned and can be used in emails with the html placeholder !!favorite_color!!.
*/
function pmpro_usermeta_in_email_data( $usermeta, $email ) {
global $current_user;
$usermeta['favorite_color'] = get_user_meta( $current_user->ID, 'favorite_color', false );
return $usermeta[0];
}
add_filter( 'pmpro_email_data', 'pmpro_usermeta_in_email_data', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment