Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/344a4d98eddf25f0fb80f3cc27bc5c01 to your computer and use it in GitHub Desktop.
Save ipokkel/344a4d98eddf25f0fb80f3cc27bc5c01 to your computer and use it in GitHub Desktop.
<?php
/**
* Set custom PMPro email data variables per locale.
*
* 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_variables_per_locale( $data, $email ) {
$user = get_user_by( 'email', $email->email );
$user_locale = get_user_locale( $user );
if ( strpos( 'en_US', $user_locale ) === false ) {
switch ( $locale ) {
case 'fr_FR':
$data['levels_url'] = 'https://example.com/fr/membership-account/membership-levels/';
break;
case 'de_DE':
$data['levels_url'] = 'https://example.com/de/membership-account/membership-levels/';
break;
}
}
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_email_data_variables_per_locale', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment