Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create a list of users from extended profile field value

  • @jcpeden

    Member

    I want to build a list of users (with links to the individual user’s profile) based on whether or not a certain value in their extended profile (already setup) matches the page.

    This function will be run inside the loop.

    I had been using CIMY extended user profiles but would prefer to handle everything through BuddyPress. How can I build a list of user profile links based on an extended profile field value?

Viewing 9 replies - 1 through 9 (of 9 total)
  • @shanebp

    Moderator

    What does this mean “matches the page” ?

    You need to know the field_id (numeric) of the profile field(s) you want to match.
    Take a look at this:
    https://buddypress.org/community/groups/creating-extending/forum/topic/search-member-profile-fields-by-url/

    @jcpeden

    Member

    Matches the page e.g. extended profile value = research group, page name = research group.

    Using the content in the link you provided, I’ve built a function that outputs a list of user ids exactly as I need it.

    Can a list of members (based on user ids) be called using this line alone or is it necessary to code the entire loop into my shortcode?

    ‘return bp_has_members($get_these_members)’

    @shanebp

    Moderator

    You don’t need the entire loop – just the parts you want.
    Using the members loop will be easier than building your own.

    @jcpeden

    Member

    Hi Shane,

    Everything is working nicely aside from the members loop. Basically, I’ve got a series of child pages. If the user’s profile info matches the child page permalink then they need to display. I had planned on using a shortcode to allow the site admin to display this members list wherever they wanted to but I’m having real trouble trying to insert the members loop into a shortcode. It causes other bits of the site to display incorrectly or brings the entire site down altogether.

    Could I use an if statement to load the members loop at the end of post content on these pages? How would you go about it?

    Thanks

    John

    @shanebp

    Moderator

    >Could I use an if statement to load the members loop at the end of post content on these pages?

    Probably.

    You have a better chance of getting help if you use pastie or gist.github to show your code.

    @jcpeden

    Member

    I’ve created a gist here:

    https://gist.github.com/2888847

    The problem, I suppose is more to do with WordPress shortcodes. I’m sure the members loop would work but I’m struggling to get it to load from within the confines of a shortcode.

    @shanebp

    Moderator

    I don’t see the members loop in your code.

    I see this:
    `$retval = “

    @jcpeden

    Member

    Hi Shane,

    The content there was just for testing purposes. CSS aside, it fell apart as soon as I tried to call any of the functions.

    I ended up creating a custom action hook, calling it at the end of post content on all pages and then coding up a custom function (available in the now-updated gist) to cross-check the permalink slug with the user’s profile information.

    It was pretty much a copy + paste job from there on out.

    Thanks for your help!

    @stanwarri

    Member

    I working on getting a list of members based on the fields they selected on the extended profiles fields in buddypress. Here is my code

    {
    global $wpdb;
    $membership_group = “Orange Membership (30,000 Naira/Year)”;
    $db_query = “SELECT user_id FROM wp_bp_xprofile_data WHERE field_id = 33 AND value = “” .$membership_group .”””;
    $match_ids = $wpdb->get_var($db_query);
    $get_these_members = ‘include=’ .$match_ids;

    if (bp_has_members($get_these_members, ‘per_page optional=9’)) { ?> //Some Codes here
    ?>
    }

    The result is returning just the first member it gets from the query instead of a list of members. Please what i’m i doing wrong.

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Create a list of users from extended profile field value’ is closed to new replies.
Skip to toolbar