Skip to:
Content
Pages
Categories
Search
Top
Bottom

Member Directory – how to add spacing between User Profile fields?


  • SimpleOne
    Participant

    @simpleone

    First off, I’m new to WordPress/BuddyPress and PHP. So I’ve been teaching myself as I go.

    How do I get spaces to be added in between the text for the Extended User Profile fields that I’ve included on the Members Directory page?

    I’ve modified the members-loop.php file to include the following line of code, but it results in the text for the Extended User Profile fields on the Members Directory page being displayed immediately next to each other (but without any spacing in between the text for those fields). What syntax do I need to use to get spaces in between the below-referenced fields Test A, Test B, Test C?

    Currently, it’s displaying on the Members Directory page like this: TestATestBTestC

    But I want it to display like this: TestA TestB TestC

    Here’s my code: echo bp_member_profile_data('field=TestA'); bp_member_profile_data('field=TestB'); bp_member_profile_data('field=TestC');

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

  • SimpleOne
    Participant

    @simpleone

    Also, what line of code would I add if I wanted the User Profile field ‘TestC’ to display on a separate line immediately underneath the line for ‘TestA Test B’.

    For example, the Members Directory page would display something like this:

    Member ATestA TestB
    TestC

    Member B
    TestA TestB
    TestC

    Member C
    TestA TestB
    TestC


    SimpleOne
    Participant

    @simpleone

    Oops… sorry I had typo in my last post. It should be

    Member A
    TestA TestB
    TestC


    shanebp
    Moderator

    @shanebp

    $str = 
    bp_get_member_profile_data('field=TestA') . ' ' .
    bp_get_member_profile_data('field=TestB') . '<br>' . 
    bp_get_member_profile_data('field=TestC');
    
    echo $str; 

    http://www.php.net/manual/en/language.operators.string.php


    SimpleOne
    Participant

    @simpleone

    Thank you! However, after trying that I got…

    Parse error: syntax error, unexpected T_ECHO

    Did I perhaps miss something? FYI, I added ?> after your snippet of code, which I assume is needed?


    shanebp
    Moderator

    @shanebp

    bp_member_profile_data('field=TestA'); 
    echo '&nbsp';
    bp_member_profile_data('field=TestB'); 
    echo '<br>';
    bp_member_profile_data('field=TestC'); 

    SimpleOne
    Participant

    @simpleone

    OK, that last one did the trick. Thanks a bunch!


    SimpleOne
    Participant

    @simpleone

    @shanebp I discovered a small issue today. On an iPad (with iOS 4.3) in the Safari browser, it incorrectly renders as:

    Member A
    TestA&nbspTestB
    TestC

    However, it renders properly (i.e., showing a space instead &nbsp) when viewing in IE or on an iPhone in Safari (with iOS 6.1).

    Is there an alternative method I can use for inserting the spaces?


    mrjarbenne
    Participant

    @mrjarbenne

    You shouldn’t need to hack the core plugin files in order to do solve the spacing issue. It’s just going to cause heartache when you update the plugin, and have to make the changes all over again. I know you are embarking on a big learning journey with BP, WP, and PHP, but I would suggest it’s time to learn a little CSS now as well. If you use a tool like Mozilla’s Firebug, you can identify the CSS identifier and tweak the CSS in a child theme (https://codex.wordpress.org/Child_Themes)

    For example, the profile field by default has a padding: 8px; in the template. If you increase that number, you will increase the spacing between the profile fields.

    Regarding adding the profile info in your member directory, this tutorial will walk you through how to pull a file from the plugin and add it to your child theme, so you can update the BP plugin more easily. It explains how to place an item on the Profile, but I’m sure the same thing could be pulled off on the Member Directory with a few tweaks.

    http://bp-tricks.com/snippets/displaying-certain-profile-fields-on-your-members-profile-page/


    SimpleOne
    Participant

    @simpleone

    @mrjarbenne, thank you very much for those helpful tips! FYI, I actually had already learned about placing my own modified files in the child theme directory. That’s actually where I’ve got the members-loop.php file placed that I’m tweaking. So I should be ok (I hope) when the time comes for me to do an upgrade to the plugin. I’ve documented every change I’ve made so I can keep track.

    Also, someone I spoke to today whose a PHP guru advised me of a solution to my last issue (re: the &nbsp still showing up on my iPad Safari browser). He told me to simply add another ; after the letter ‘p’. And it worked! My iPad now renders the spaces properly!

    Here’s the way that snippet of code looks now: ‘&nbsp;‘;


    SimpleOne
    Participant

    @simpleone

    And btw, I do intend to teach myself CSS. I fully realize the value of knowing it. I’ve learned a few things about it already in the last couple of weeks, but I have so much more to learn. I definitely appreciate your advice and suggestions.


    mrjarbenne
    Participant

    @mrjarbenne

    I don’t think the learning ever stops. Cheers.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Member Directory – how to add spacing between User Profile fields?’ is closed to new replies.
Skip to toolbar