Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom Display on Members Directory

  • Avatar of SimpleOne
    SimpleOne
    Participant

    @simpleone

    I’ve modified the members-loop.php file so that my Members Directory page will display the list of members in a certain way (as shown below, for example purposes).

    Member 1
    Small Poodle
    Los Angeles

    Member 2
    Large Collie
    Boston

    Member 3
    Large Dalmatian
    Chicago

    Member 4
    N/A No Dog
    Miami

    Following is the code I’ve placed in the members-loop.php file to successfully display the above results on the Members Directory page.

    bp_member_profile_data('field=Dog Size'); 
    echo ' '; 
    bp_member_profile_data('field=Dog Breed'); 
    echo '<br>'; 
    bp_member_profile_data('field=Dog Weight'); ?>

    Question: Is it possible for me to not display the line for ‘N/A No Dog’ whenever a member has specificed “No Dog” in the ‘Dog Breed’ field on their profile? For example, in the above, I still want the Member 4 to be shown in the list of all members. However I do not want the ‘N/A No Dog’ line (which comes from the Dog Size and Dog Breed fields entered on their profile) to be displayed underneath their username. I would only want their location, Miami, to be shown.

    Is this possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of SimpleOne
    SimpleOne
    Participant

    @simpleone

    Anyone?

    Avatar of SimpleOne
    SimpleOne
    Participant

    @simpleone

    As an alternative solution, is it possible to exclude all members in the above list if they had selected ‘N/A’ for Dog Breed?

    (And btw, in my code snippet above, I meant to type ‘Location’ instead of ‘Dog Weight’. Just wanted to clarify that to avoid any potential confusion about what I coded vs. the displayed results above.)

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    >As an alternative solution, is it possible to exclude all members in the above list if they had selected ‘N/A’ for Dog Breed?

    Yes, there are 2 ways:

    1) http://codex.buddypress.org/plugindev/using-bp_parse_args-to-filter-buddypress-template-loops/
    2) http://codex.buddypress.org/developer/loops-reference/the-members-loop/#code-examples

    >Is it possible for me to not display the line for ‘N/A No Dog’ whenever a member has specificed “No Dog” in the ‘Dog Breed’ field on their profile?

    Yes, use bp_get_member_profile_data instead:

    $dog_size = bp_get_member_profile_data('field=Dog Size'); 
    if ( $dog_size != false ) echo $dog_size;
    Avatar of SimpleOne
    SimpleOne
    Participant

    @simpleone

    @shanebp thanks for all of that VERY helpful info and guidance (including the links to code examples)! It is very much appreciated.

    For now, I opted to go with not displaying the line for “N/A No Dog’ whenever a member has specified such.

    Question… by using this type of code (i.e., the snippet you provided above) in my members-loop, will it result in performance issues on my database? Like if my site grows to thousands of users at some point, will I encounter any performance issues?

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

You must be logged in to reply to this topic.