Skip to content

Instantly share code, notes, and snippets.

@MaryOJob
Created January 16, 2020 23:40
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 MaryOJob/c39734bca4b541e640b59c21ff243c84 to your computer and use it in GitHub Desktop.
Save MaryOJob/c39734bca4b541e640b59c21ff243c84 to your computer and use it in GitHub Desktop.
Show WordPress email on BuddyPress user xprofiles page
<?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