Last active
March 21, 2024 14:02
-
-
Save ipokkel/4a5d3f2ca051f880f20069198ccc71ec to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* 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