Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to list user from a specific profile data ???

  • Avatar of beppe999
    beppe999
    Member

    @beppe999

    Hello guys,
    i’m new on BuddyPress. I would like to list the users of a specific profile data.

    Let me explain…

    I’ve a “tipology” field where the users can choose for example type1, type2, type3
    I would like to list, in a custom loop page, only the user from tipology > type3

    I’m using this loop but it doesen’t work

    `

    `

    I need your help, do you have an idea?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    `bp_get_member_profile_data` is only specific to one member. It will not grab all users with a certain xprofile field nor is there a built-in function that will do what you want.

    I’d write a custom function to return the user IDs that match a certain field. Then use the `include` parameter in the members loop to do what you want to do.

    eg. `if ( bp_has_members( ‘include=’ . my_custom_function() ) ) : `

    `my_custom_function()` will have to be written!

    If you know your way around WordPress, check out the `wp_bp_xprofile_data` table in your DB and a way to query the WPDB for hints. The `xprofile_get_field_id_from_name()` function will help as well.

    Avatar of beppe999
    beppe999
    Member

    @beppe999

    @r-a-y
    Many thanks.

    Avatar of beppe999
    beppe999
    Member

    @beppe999

    @r-a-y
    Hi,
    this is the solution I found with your help, what you think?

    `

    bp_get_member_user_id(),’field’=>typology )); ?>

    `

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    @beppe999 – That’s one way of doing it. It’s a quick way to achieve what you want, however you lose the ability to properly paginate and to grab a specific amount of members.

    Avatar of mistercyril
    mistercyril
    Participant

    @mistercyril

    Hello,
    I have a silly question for you. Where does this code go?
    Does it go in a new members-loop.php file or a custom template?
    Thanks for the pointers,
    C.

    Avatar of mistercyril
    mistercyril
    Participant

    @mistercyril

    Ok, nevermind. That was a very silly question ;-)

    @r-a-y its true that pagination is all messed up. What is the better way of doing this?

    I would guess this has to be done higher in the loop. I’m using this to get members displayed alphabetically and it works ok. Could this be used to select users based on custom profile field values as well?

    `<?php
    if ( bp_ajax_querystring( ‘members’ ) ==””)
    {
    $queryString = “type=alphabetical&action=alphabetical&per_page=150″;
    }
    else {
    $queryString = bp_ajax_querystring( ‘members’ );
    }
    ?>

    `

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

You must be logged in to reply to this topic.