Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created September 16, 2022 09:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ipokkel/d3206dab7f75567f1317b976afb10998 to your computer and use it in GitHub Desktop.
Save ipokkel/d3206dab7f75567f1317b976afb10998 to your computer and use it in GitHub Desktop.
Show user's email address in place of the login name in the "Your are logged in as" message on the PMPro checkout page.
<?php
/**
* Replace user's login displayed to email address in the "You are logged in as"
* on the PMPro checkout page.
*
* 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_gettext_checkout_email_in_logged_in_message( $translated_text, $original_text, $domain ) {
global $current_user;
if ( 'paid-memberships-pro' === $domain ) {
if ( 'You are logged in as <strong>%s</strong>. If you would like to use a different account for this membership, <a href="%s">log out now</a>.' === $original_text ) {
$translated_text = 'You are logged in as <strong>' . esc_html( $current_user->user_email ) . '</strong><span style="visibility: hidden; display: none;">%s</span>. If you would like to use a different account for this membership, <a href="%s">log out now</a>.';
}
}
return $translated_text;
}
add_filter( 'gettext', 'my_pmpro_gettext_checkout_email_in_logged_in_message', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment