Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How do display wordpress email in buddypress profile?


  • screampuff
    Participant

    @screampuff

    Hello, I have an internal company site so privacy is not an issue.

    I want the Buddypress profile of each user to display each person’s wordpress account email address with a mailto link.

    Is there an easy way to accomplish this?

Viewing 9 replies - 1 through 9 (of 9 total)

  • Brajesh Singh
    Participant

    @sbrajesh

    Hi,
    It is easy to do that.
    Here is a function, you can put it in your bp-custom.php or your theme’s functions.php

    
    function devb_show_displayed_user_email() {
    	
    	if( ! bp_is_user() )
    		return ;
    	
    	$user_email = bp_get_displayed_user_email();
    	
    	echo "<a href='mailto:{$user_email}'>{$user_email}</a>";
    }

    And you can call it on the user profile like this

    
    <?php devb_show_displayed_user_email();?>
    
    

    and It will show the email as links.

    Hope that helps.


    tiquality
    Participant

    @tiquality

    hy Brajesh!

    I dont understand where can I call the function on the profile, what is the file that I should insert the code <?php devb_show_displayed_user_email();?>?


    Brajesh Singh
    Participant

    @sbrajesh

    Hi,
    Is your theme BuddyPress compatible, if yes, Please check if there is ‘members/single/member-header.php or buddypress/members/single/member-header.php

    If yes, you can put the code anywhere in that file. If your theme does not have this file, It can be added via ‘bp_member_header_actions’ too like this

    
    add_action('bp_member_header_actions', 'devb_show_displayed_user_email' );
    

    which you can put in the bp-custom.php too.


    tiquality
    Participant

    @tiquality

    Thanks Brajesh, but I didnt find this files, bp-custom.php and member-header.php 🙁

    This is my link profile project: http://tiquality.com.br/intranet/members/admin/profile/

    On the extend profile fields, it should show the mail of wordpress user.

    tks!


    danbp
    Moderator

    @danbp

    hi @tiquality,

    to show the user’s mail above the other user information, you can add the following snippet to bp-custom.php or child-theme’s functions.php

    Assuming users gave a valid email at registration, we can output that address.
    Avantage is that they haven’t to enter their mail a second time while completing their profile.

    So we just need to manually add this address to the template, using one of the action hook avaible in profile-loop.php

    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">Contact me</td>
    
    				<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');

    If you prefer it on the profile header, use the action hook indicated by Brajesh
    add_action('bp_member_header_actions', 'tiquality_add_custom_field');


    tiquality
    Participant

    @tiquality

    hello!

    thanks so much my friend for the help.

    I Inserted the code “function tiquality_add_custom_field() {” in profile-loop.php and inserted the “add_action(‘bp_member” in the functions buddypress, and the result was not ok, see: http://tiquality.com.br/intranet/members/ayrton/profile/


    tiquality
    Participant

    @tiquality

    Wait!!! No I got sucessfull! @danbp I inserted this code on the buddypress-functions.php in the bp-templates\bp-legacy folder, and it is fantastic, very great!

    http://tiquality.com.br/intranet/members/mallandro/profile/

    Thanks guys, very thanks for your help!


    danbp
    Moderator

    @danbp

    No, you do it wrong. Read the codex links i provided.

    buddypress-functions.php in the bp-templates\bp-legacy folder or profile-loop.php are not the right files.

    I told you to put the snippet into bp-custom.php OR in your child-theme functions.php

    Why do you hack core files ? They will be overwriten at next BP update… 👿


    tiquality
    Participant

    @tiquality

    OK @danbp, I created the bp-custom.php and cleaned the budypress-functions.php. its ok 100%.

    I am just a beginner. Thanks again for your help!

    bye bye!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] How do display wordpress email in buddypress profile?’ is closed to new replies.
Skip to toolbar