Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Custom Display on Members Directory


  • 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)

  • SimpleOne
    Participant

    @simpleone

    Anyone?


    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.)


    shanebp
    Moderator

    @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) https://codex.buddypress.org/plugindev/using-bp_parse_args-to-filter-buddypress-template-loops/
    2) https://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;

    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)
  • The topic ‘[Resolved] Custom Display on Members Directory’ is closed to new replies.
Skip to toolbar