Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active March 21, 2024 14:02
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/4a5d3f2ca051f880f20069198ccc71ec to your computer and use it in GitHub Desktop.
Save ipokkel/4a5d3f2ca051f880f20069198ccc71ec to your computer and use it in GitHub Desktop.
<?php
/**
* Hide the email address from the member directory.
*
* 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 remove_user_email_address_from_member_profile( $value, $original_value, $field_name ) {
// Add the email addresses you want to hide here.
$remove_email_addresses = array( 'johndoe@example.com', 'janedoe@example.com' );
if ( 'user_email' === $field_name && ( in_array( $value, $remove_email_addresses ) || in_array( $original_value, $remove_email_addresses ) ) ) {
return ''; // return empty string to hide email address
}
return $value;
}
add_filter( 'pmpromd_format_profile_field', 'remove_user_email_address_from_member_profile', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment