Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

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

  • r-a-y
    Keymaster

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

    @r-a-y
    Many thanks.

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

    `

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

    `


    r-a-y
    Keymaster

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


    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.


    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’ );
    }
    ?>

    `


    mohammad
    Participant

    @duablellc

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to list user from a specific profile data ???’ is closed to new replies.
Skip to toolbar