This topic has 6 replies, 2 voices, and was last updated 7 years by Laura.

  • Author
  • #158365
     joy
    Participant

    Hello, I have added a couple functions to display additional fields in the profile header. I am using the following code in my functions.php file. This displays the users location and the social icons.

     

    // Add Location to profile

     

    add_action( ‘bp_profile_header_meta’, ‘display_user_location’ );

    function display_user_location() {

    $args = array(

    ‘field’ => ‘Location’, // Field name or ID.

    );

    $location = bp_get_profile_field_data( $args );

     

    if ($location) {

    echo ‘Location ‘ . $location;

     

    }

     

    }

     

     

     

    /* adding social media icons to profile */

    add_action(‘bp_profile_header_meta’,’social_links_in_header’);

     

    function social_links_in_header () {

    $social_links = array(‘facebook’,’twitter’,’google+’,’instagram’,’linkedin’,’youtube’,’pinterest’, ‘link’);

    foreach( $social_links as $link ) {

    if ( $data = bp_get_profile_field_data( array(‘user_id’=>bp_displayed_user_id(), ‘field’=>$link )) ) : ?>

    <?php

    if ($link == ‘google+’) {

    $iconlink = ‘gplus’;

    } elseif ($link == ‘pinterest’) {

    $iconlink = ‘pinterest-circled’;

    } elseif ($link == ‘instagram’) {

    $iconlink = ‘instagramm’;

     

    } else {

    $iconlink = $link;

    }

    ?>

    <a href=”<?php echo bp_get_profile_field_data( array(‘user_id’=>bp_displayed_user_id(), ‘field’=>$link)); ?>” target=”_blank”><i class=”icon-<?php echo $iconlink; ?>”></i></a>

    <?php endif;

    }

    }

    How do I add a line break between the two values? It currently shows on the same line and I can’t figure it out. Thank you.

    #158435
     Laura
    Moderator

    Hello, try by adding <br> or </br> before the <a href of the second code, let me know if that works 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #158481
     joy
    Participant

    I already tried that. If I place it within the a href=”…, it has no effect. If I place it before <br><a href=”…, all of the icons are displayed in a vertical line.

    #158504
     Laura
    Moderator

    Hello, please share access so i can check it out, it could be fixed with css.
    Always happy to help 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #158511
     joy
    Participant
    This reply has been set as private.
    #158576
     joy
    Participant

    Not sure what I did, but it’s fixed.

    #158686
     Laura
    Moderator

    Glad you could resolve it! 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?