Created
January 16, 2020 23:40
-
-
Save MaryOJob/c39734bca4b541e640b59c21ff243c84 to your computer and use it in GitHub Desktop.
Show WordPress email on BuddyPress user xprofiles page
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 // do not copy this line, doing so will give you a fatal error when you run this script | |
/* | |
If you are using this code, please be aware of privacy laws in your region and also beware of spambots harvesting your users' | |
emails from your website. | |
*/ | |
function tiquality_add_custom_field() { | |
if ( bp_is_active( 'xprofile' ) ) : | |
if ( is_user_logged_in() ) { | |
?> | |
<div class="bp-widget <?php bp_the_profile_group_slug(); ?>"> | |
<table class="profile-fields"> | |
<tr class="my_mail"> | |
<td class="label">Email</td> // You can give any title you want here instead of 'Email' | |
<td class="data"><a href="mailto:<?php bp_displayed_user_email(); ?>"><?php bp_displayed_user_email(); ?></a></td> | |
</tr> | |
</table> | |
</div> | |
<?php | |
} | |
endif; | |
} | |
add_action('bp_profile_field_buttons', 'tiquality_add_custom_field'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment