Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display Certain Profile Fields in Sidebar


  • webusat
    Participant

    @webusat

    Hi,

    I am trying to place information from certain profile fields in the sidebar whenever a persons profile is displayed. I think I also want to to stay there in the sidebar as long as a user is viewing that profile. Anyhow, I can get it to display and work like that except for the formatting. No matter how the users fills in that data using the WYSIWYG editor it all runs together. Here is the code I am using:

    $profile = bp_get_profile_field_data('city partners');
    
    if ( !empty($data) && strlen($data) > 0 ) {
      echo "<h4>City Resources</h4>";
      echo $profile;
    }

    It displays all together like this:
    City Hall Ut et dui pulvinar diam suscipit cursus. Nulla est tellus, rutrum non euismod nec, rutrum et ligula. Etiam eget nunc congue, convallis dolor eget, volutpat arcu. Sed velit tellus, pretium eu ante eu, auctor laoreet sapien. Gramercy Park Suspendisse sollicitudin tempus mauris, quis sollicitudin nisi euismod ac. Sed sit amet tincidunt nibh. Aenean non magna mauris. Link here

    or if a single line it all just runs together. In the body of the profile page it looks like it does in the editor and how it should with the formatting:
    City Hall

    Ut et dui pulvinar diam suscipit cursus. Nulla est tellus, rutrum non euismod nec, rutrum et ligula. Etiam eget nunc congue, convallis dolor eget, volutpat arcu. Sed velit tellus, pretium eu ante eu, auctor laoreet sapien.

    Gramercy Park

    Suspendisse sollicitudin tempus mauris, quis sollicitudin nisi euismod ac. Sed sit amet tincidunt nibh. Aenean non magna mauris. Link here

    ———-

    All nice and neat which is how I want it. How can I keep the formatting, spacing, line breaks, etc.?

    Thanks,
    Stan

    I am running the BuddyPress 4.1.0 and WP 4.4.9.

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

  • shanebp
    Moderator

    @shanebp

    Have you tried using wpautop ?


    webusat
    Participant

    @webusat

    Hi, I had never heard of that so thank you, so far it seems to work! Why do we have to do that? Anyhow, we will test some more and post back.

    One other question. Which is better or does it matter:

    $data = bp_get_profile_field_data( 'field=city resources' );

    or

    $data = xprofile_get_field_data('city resources');

    Thanks!
    Stan


    shanebp
    Moderator

    @shanebp

    When not on a profile screen, use xprofile_get_field_data and pass in the user’s ID.

    xprofile_get_field_data


    webusat
    Participant

    @webusat

    Hi,

    I understand now. Like this:

    xprofile_get_field_data( 'city partners', $user_id = 0 )

    Stan


    webusat
    Participant

    @webusat

    Hi,

    This is solved and below is what i used to make the field display on the users profile page and in the sidebar:

    
    if ( bp_is_active( 'xprofile' ) ) {
    	$data = bp_get_profile_field_data( 'field=YOUR FIELD NAME' );
    	if ( !empty($data) && strlen($data) > 0 ) {
    	echo "<h4>OUR FIELD NAME</h4>";
    	echo wpautop($data);
      }
    }
    

    Thanks for the help!
    Stan


    webusat
    Participant

    @webusat

    Hi,

    I have one more question.

    The data appears both in the content area and the sidebar. Is there a way to limit it or control where the fields appear so it doesn’t appear in both places?

    Thanks,
    Stan


    webusat
    Participant

    @webusat

    Hi,

    I am controlling what appears where by using this code:

    <?php $groupid = bp_get_the_profile_group_id();
    // enter group id in array
    if( in_array($groupid, array(1,2,3,4)) ) : ?>
    

    Stan

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