Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get users using specific profile field


  • k4tn1x
    Participant

    @k4tn1x

    Hi !
    I want to get users filtering by a specific extended profile field, for example :
    I want all users where extended profile field “enterprise” value is “WordPress”. How can I do this please ?
    For now i’m using get_users() to get all users and I display their extended profile fields with bp_profile_field_data().

    Thank you and have a good day !

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

  • buddycore
    Participant

    @buddycore

    You’re going into a pretty complicated MySQL query.

    $field_id = SELECT id FROM wp_bp_xprofile_fields WHERE name = Profile Field

    $users = SELECT DISTINCT user_id FROM wp_bp_xprofile_data WHERE value = enterprise AND field_id = $field_id

    Then you’re gonna be implementing a foreach loop in PHP.

    That’s the approach I would take, it’s quite in-depth and I’m working on something else at the moment but hopefully that gives you an idea of where to look.


    k4tn1x
    Participant

    @k4tn1x

    Thank you ! I’ll look to this MySQL query !


    danbp
    Moderator

    @danbp

    Normally profile field values are clickable and by doing this, each visitor can see a list of user who entered the same value. This is buit-in and intended to work on profiles.

    Another approach would be to associate a member type to that value.
    MT lets you create specific Member Directory.

    Member Types

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar