Skip to:
Content
Pages
Categories
Search
Top
Bottom

display profile fields in member header


  • cdb3212
    Participant

    @cdb3212

    The goal is to display all xprofile data from users to the right of their avatar, with the clickable URL links still intact – the way it is under the user Profile page.

    I know this problem has been addressed in the past, but I cannot get this to work for the life of me. I followed this as a guide, with no success.

    I copied the single/member-header.php from the bp-templates/bp-legacy directory in to my child-theme.

    This is what my member-header file looks like right now:

    
    <?php
    		
    		 If you'd like to show specific profile fields here use:
    		 bp_profile_field_data( 'field=location' ); -- Pass the name of the field
    		 
    		 do_action( 'bp_profile_header_meta' );
    
    		 ?>
    

    The location field is a custom one that I made.

    I’m running the latest version of buddypress and using a child-theme of twentyfourteen.

    I appreciate any help.

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

  • Renato Alves
    Participant

    @espellcaste

    @cdb3212 As far as I understood your problem, there are two articles that would save your life if you had a chance of looking in the Codex. These are:

    https://codex.buddypress.org/getting-started/guides/displaying-extended-profile-fields-on-member-profiles/

    bp_profile_field_data()

    Take a look at those and try it out. =)


    cdb3212
    Participant

    @cdb3212

    @espellcaste

    Thank you for your help. I tried following that guide, but with no success. The changes I am making in my member-header file in my child theme are not being reflected on my site. I even went as far as deleting everything in the file and typing “abc” just to see what happens. Nothing changed.

    I was careful in copying the directory over in my child theme, but it just doesn’t seem to be overriding the default file.

    I needed to copy the bp-legacy directory, not the bp-default directory, correct?


    cdb3212
    Participant

    @cdb3212

    @barney92

    I added that code to my bp-custom file, no results. Which file do I add that code to?

    I appreciate your help.


    Renato Alves
    Participant

    @espellcaste

    @cdb3212 As embarrassing as this might sound, I don’t know how Child Themes works exactly, but it seems there is a problem where you are putting it.

    Try using @barney92 suggestion, putting it in your functions.php file within your theme and see the result.


    shanebp
    Moderator

    @shanebp

    @barney92

    @espellcaste

    I believe the OP wants the code in member-header, not in members directory.

    So pointing them to awkward code that isn’t relevant is not very helpful.

    The OP’s issue is with their template over-ride for member-header.php


    @cdb3212

    paste the path to your over-ride so we can see if it’s in the right place.

    Use https://gist.github.com/ to show us the current contents of that over-ride


    Lerroy
    Participant

    @lerroy

    Arguments aside.

    I actually need the same thing would like to show Users full name above his @username and show State field and About/ bio field

    Have been reading the buddypress documentation with no luck and searching forums.


    cdb3212
    Participant

    @cdb3212

    @shanebp : public_html/wp-content/themes/twentyfourteen-child/single

    and then the member-header.php is included in the “single” folder.

    Here are the contents

    @barney92 , @shanebp is just trying to help, man. He didn’t call you out in particular. Can’t we all be friends?


    Lerroy
    Participant

    @lerroy

    @Barney

    Thanks for pointing me to that.

    I’m still struggling though PHP aint my thing 🙁

    So the primary field “Name” and my other fields are called “State: and “Organization” and “Website” these are the field names I insert ?

    Heres where i put it..But doesnt show full member-header

    ` </div><!– #item-buttons –>

    <?php
    /***
    * If you’d like to show specific profile fields here use:
    * bp_member_profile_data( ‘field=About Me’ ); — Pass the name of the field
    */
    do_action( ‘bp_profile_header_meta’ ); // Here is one way you could add xprofile fields name as well as the value to the members directory!
    // Just remember to replace “Field-Name” with the names of your fields in the 5 variables in my code.
    // Also remember the field name is case sensitive. If you notice the pattern of 5 in my code you can
    // easily see how to add more fields if you need them. You can also use the div class bph_xprofile_fields
    // to adjust the CSS in your stylesheet. Place this code in bp-custom.php:
    add_action(‘bp_directory_members_item’, ‘bphelp_dpioml’);
    function bphelp_dpioml(){
    $bphelp_my_profile_field_1=’Name’;
    $bphelp_my_profile_field_2=’State’;
    $bphelp_my_profile_field_3=’Organisation’;
    $bphelp_my_profile_field_4=’Website’;
    $bphelp_my_profile_field_5=’About-you’;
    if( is_user_logged_in() && bp_is_members_component() ) { ?>
    <div class=”bph_xprofile_fields” style=” margin-left: 25%;”>
    <?php echo $bphelp_my_profile_field_1 ?>: <?php echo bp_member_profile_data( ‘field=’.$bphelp_my_profile_field_1 ); ?><br />
    <?php echo $bphelp_my_profile_field_2 ?>: <?php echo bp_member_profile_data( ‘field=’.$bphelp_my_profile_field_2 ); ?><br />
    <?php echo $bphelp_my_profile_field_3 ?>: <?php echo bp_member_profile_data( ‘field=’.$bphelp_my_profile_field_3 ); ?><br />
    <?php echo $bphelp_my_profile_field_4 ?>: <?php echo bp_member_profile_data( ‘field=’.$bphelp_my_profile_field_4 ); ?><br />
    <?php echo $bphelp_my_profile_field_5 ?>: <?php echo bp_member_profile_data( ‘field=’.$bphelp_my_profile_field_5 ); ?><br />
    </div><?php
    }
    }

    ?>’


    Lerroy
    Participant

    @lerroy

    Ok
    After allot more research I found a solution. looks like I was putting your code in the wrong spot sure it would have worked as well @Barney

    I used this code

    <?php
       
      $state = bp_get_profile_field_data( 'field=State' ) ;
    echo '<p class="profile-fields">State: ' .$state. '</p>';
    ?>

    This displays my custom field state that i added via users > profile feeds in backend of wordpress

    I put this code under

    <span class="activity"><?php bp_last_activity( bp_displayed_user_id() ); ?></span>

    this is all in the members_header.php in the bp_legacy section

    @barney92 A final warning: Please do not resort to insulting forum members, it’s not to be tolerated.

    @barney92 Not really the best way of responding nor is having a ‘lousy week’ an excuse I’m afraid, lets just back off the forum until we are having a better week is generally the best approach.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘display profile fields in member header’ is closed to new replies.
Skip to toolbar