Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display email in member header WITH link


  • wpsouf
    Participant

    @wpsouf

    Hello,
    I add member email information to the member header in profil member. For that, i use this code :

    <?php $email = bp_displayed_user_email(); ?>

    <?php if ( ! empty( $fonction ) ) { ?>
    <span class=”thrive-member-role”>
    <?php echo esc_html( $email ); ?>
    </span>
    <?php } ?>

    Now, i need to add a mailto link to this code.

    Please any help ?

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

  • danbp
    Participant

    @danbp

    Hi,

    try:
    echo '<a href="mailto:'. bp_displayed_user_email().'>'. bp_displayed_user_email(); .'</a>';


    wpsouf
    Participant

    @wpsouf

    Danp, thank for your return.

    Should i replace all my code with yours ? or just a part of it ?


    danbp
    Participant

    @danbp

    If your code was working, you change only the echo who fires the mailto link.


    wpsouf
    Participant

    @wpsouf

    Like this ? :

    <?php $email = bp_displayed_user_email(); ?>

    <?php if ( ! empty( $fonction ) ) { ?>
    <span class=”thrive-member-role”>
    <?php echo ‘‘. bp_displayed_user_email(); .’‘; ); ?>
    </span>
    <?php } ?>


    wpsouf
    Participant

    @wpsouf

    i can’t figure out…

    My first code is working. i want just add a mailto link.

    Can you please, if possible, give me the exact code based on my original code ?

    (i’m just beginner…)


    danbp
    Participant

    @danbp

    Oh, copy/pasting is out of scope today ? 😉 Your code, corrected.

    <?php $email = bp_displayed_user_email(); ?>
    <?php if ( ! empty( $fonction ) ) { ?>
    <span class=”thrive-member-role”>
    <?php echo '<a href="mailto:'. bp_displayed_user_email(); .'">'. bp_displayed_user_email(); .'</a>'; ?>
    </span>
    <?php } ?>

    wpsouf
    Participant

    @wpsouf

    yeah exactly :p

    The code is not working, unfortunately… i get a blank page.


    danbp
    Participant

    @danbp

    Sorry, missed a semi-colon… Snippet is corrected.


    wpsouf
    Participant

    @wpsouf

    Ok.
    But where is the corrected code ?


    danbp
    Participant

    @danbp

    In my previous answer, i corrected the snippet.


    wpsouf
    Participant

    @wpsouf

    Ok, sorry.
    But still not work…


    wpsouf
    Participant

    @wpsouf

    Hello,

    The issue is that i was using bp_displayed_user_email() this function echo’s the email of a user, i should use bp_get_displayed_user_email() this function returns the email of a user.

    So @danbp your code was correct, it was my function… 🙂

    Here is the corrected code :

    <?php $user_email = bp_get_displayed_user_email(); ?>
    <span class=”thrive-member-role”>
    <?php echo’‘ . $user_email . ‘‘; ?>
    </span>

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.
Skip to toolbar