Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display random member list


  • rogueeasyweb
    Member

    @rogueeasyweb

    Hello,

    I’m trying to figure out how to display random member list on the member directory page. I have looked at this page http://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-members-loop/ and have a vague handle on doing this. What file might I edit to perform the change? And the line of code to use?

    I was looking at members-loop.php line 16

    …but I think I wonder if I’m barking up the wrong tree as bp_has_members appears in several other files also. Sorry, PHP Noob here!

    I thought this may have been covered before, so I tried searching but the forum search seems to be broken or..?

    Buddypress 1.5.3.1
    Wordpress 3.3.1
    Default buddypress theme 1.5.3.1

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

  • rogueeasyweb
    Member

    @rogueeasyweb

    nobody?

    What do you mean exactly by a “random member list”? Members are listed at random in any order?


    Sarah Lewis
    Participant

    @bookchiq

    Replying well after the fact to help any other Google searchers who come across this page:

    Add something like the following code to your theme’s functions.php file:

    add_action( 'bp_members_directory_order_options', 'bp27845_add_random_order_option' );
    function bp27845_add_random_order_option() {
    	echo '<option value="random">' . __( 'Surprise me!', 'buddypress' ) . '</option>';
    } // end bp27845_add_random_order_option

    This code takes advantage of the bp_members_directory_order_options action hook to insert a new option, which then sets bp_has_members()‘s type to random (the value we’re sending).

    A more in-depth tutorial: https://codex.buddypress.org/plugindev/add-custom-filters-to-loops-and-enjoy-them-within-your-plugin/#add-a-custom-filter-to-the-members-groups-and-blogs-loops


    somethingelse
    Participant

    @somethingelse

    i am still a bit confused as to why this idea is so difficult to achieve.

    is it not common to want to flatten the hierarchy of members and just display the list at random, period? i don’t want visitors to have to use a dropdown list to choose what order members are displayed in. I want members displayed in random order, 12 to a page, period, with the search box at the top. So every time a new visitor comes by there’s a random group of 12 on the first directory page. That way, in theory, we are not showing any kind of favoritism and the folks who start with “a” don’t get an unfair amount of visibility.

    i can get the 12 to a page, and the search box… but for the life of me i can’t get RANDOM.
    it insists on using ONLY the active members at random, not ALL members, and frankly, our members aren’t that active – this is a directory, not a community – the members come in once, update their profile, and go away – then joe public comes by and looks for them… to find one in their neighbourhood.

    why is it so hard? 🙂 or am i just that dense?
    i’ve tried using $query_string .= '&per_page=12&type=random'; in my function and all i get are the 6 who look at themselves the most 🙂 if use type=alphabetical, i get everyone, but then…. wait for it… they are alphabetical…
    i’ve tried combining types, and there seems to be a hierarchy still…

    please help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display random member list’ is closed to new replies.
Skip to toolbar