Members Loop Output

Good evening, all!

I am having a hard time modifying the members-loop output.

Essentially, I want to check the value of a profile field and output fields based on that value.

Here’s what I was trying, but it’s outputting everything regardless.

In the theme/members/members-loop.php file, there’s a section where you can output additional fields.

Is there a function that gets the raw value versus the echo, as bp_member_profile_data( ‘field=Member Type’ ); seems to do?

Here’s a quick look at what I’m doing.

/*Set Up Stylist Data */

$type = bp_member_profile_data( 'field=Member Type' );

if ($type = 'Stylist'){

$salon = bp_member_profile_data( 'field=Stylist Salon Name');

}

if ($type = 'Stylist'){

echo $type. ' at ' .$salon;

}

You can see the output result here:

http://baltimoresbeststylist.com/b/members/

I appreciate any insight. I’ve been looking for a BP function list, but not having much luck.

  • Richie_KS
    • HummingBird

    try this

    /*Set Up Stylist Data */

    $type = bp_member_profile_data( 'field=Member Type' );

    if ($type = 'Stylist'){

    $salon = bp_member_profile_data( 'field=Stylist Salon Name');

    }

    if ($type == 'Stylist'){

    echo $type. ' at ' .$salon;

    }

    use ‘==’ instead of ‘=’ for the second contional check..

  • candacekthe1
    • Flash Drive

    Thanks for the reply, Richie!

    I was toying around with different variations of = and == without knowing enough about it. :slight_smile:

    I’m still getting funky stuff, though.

    It’s weird; it’s like even setting the variable is outputting the Member Type.

    EXAMPLE:

    Member avatar

    Candace Cottrell StylistBella SalonStylist at

    Zip: 21202

    Hair Stylist, Makeup Artist, Fashion Advisor

    Relationship Status: Accepting New Clients

    Specialties: Color Urban, Special Occasions, New Me, Everyday

    Hours: 9am-5pm

    Accepting New Clients

    active 0 seconds ago

  • candacekthe1
    • Flash Drive

    Oooh, that’s closer. But now it looks like it’s taking the first value and applying it to everyone in the loop.

    I added a bit more conditional logic:

    /*Set Up Stylist and Salon Data */

    $type = bp_get_member_profile_data( 'field=Member Type' );

    if ($type = 'Stylist'){

    $salon = bp_get_member_profile_data( 'field=Stylist Salon Name');

    echo $type. ' at ' .$salon;

    }

    else if ($type = 'Salon'){

    $salon = bp_get_member_profile_data( 'field=Salon Name' );

    echo $salon;

    }

    I also tried using bp_the_profile_field_value(4);

    and passing the field ID, but that doesn’t return anything at all.

    and passing the same param bp_the_profile_field_value(‘field=Zip code (home)’:wink:;

    I wish there was a list somewhere of which functions to use and when. I feel like an idiot!

    Thanks for your help Richie!

  • Richie_KS
    • HummingBird

    it should be working ok with the member loop…what version of buddypress you’re using since

    there’s some changes in directory member loop code prior to 1.2 below…try debug the code by adding this to

    your-theme/members/members-loop.php

    start at

    <?php while ( bp_members() ) : bp_the_member(); ?>

    <?php

    $dname = bp_get_member_profile_data( ‘field=Display Name’ );

    echo $dname;

    ?>

    ////the rest of the code////

    add the bold code somewhere near the while code…and check if each members display name echo correctly..if yes then the other field shouldn’t have problems…field name are case sensitive tho..it won’t fetch ‘display name’ but will fetch ‘Display Name’

    cheers

  • candacekthe1
    • Flash Drive

    Richie,

    Just wanted to pop in and thank you. You were right; this is the correct logic:

    /*Set Up Stylist and Salon Data */

    $type = bp_get_member_profile_data( 'field=Member Type' );

    if ($type == 'Stylist'){

    $salon = bp_get_member_profile_data( 'field=Stylist Salon Name');

    }

    else if ($type == 'Salon'){

    do something else here

    }