Random sort

BP Profile Search › Random sort

  • Author
    Post
  • #9574 Reply
    LOIC
    Guest

    Hi,
    Is it possible to randomly sort results ?
    With this kind of shortcode for exemple (gwangi theme/ swap page) : [bps_directory template=”members/index-swap” order_by=”random”]

    Best regards !

    #9576 Reply
    andrea
    Plugin Author

    Hi LOIC,

    That’s a nice feature, it’s not available yet but I’m adding it to my to-do list. Thank you!

    #10272 Reply
    Dominik
    Guest

    Hello Andrea,
    i’m very intrested in that function too.
    Would be awesome to get a result page with random users. (Need it form my members swap.) Glat to hear from you.

    Cheers
    Dominik

    #10277 Reply
    andrea
    Plugin Author

    Hello Dominik,

    I still have that feature in my to-do list, but I moved it to low priority because I found it difficult to implement correctly. I’m sorry I’m not able to help!

    #10300 Reply
    David
    Guest

    “I moved it to low priority because I found it difficult to implement correctly”

    Man, please…

    You have to implement this POWER feature 🙂

    It will be really usefull.

    #10315 Reply
    andrea
    Plugin Author

    Hi all,

    A simple solution could be to add this code to your bp-custom.php file:

    add_filter ('bp_user_query_uid_clauses', 'random_order', 10, 2);
    function random_order ($sql, $object)
    {
    	$request = bps_get_request ('search');
    
    	if (count ($request) > 1)
    		$sql['orderby'] = 'ORDER BY rand()';
    
    	return $sql;
    }

    Please let me know if it works for you!

    #10364 Reply
    BeeNC
    Guest

    Thanks I will try it.
    Do you think that it would be possible to filter only profiles with picture / avatar ?

    Have a nice day
    Loïc

    #10365 Reply
    andrea
    Plugin Author

    Hi Loïc,

    Right now it’s not possible, it’s another thing on my to-do list.

    #10690 Reply
    BeeNC
    Guest

    Can we make it work within function.php file ?
    What is the parameter of the shortcode we have to add ?

    #10691 Reply
    andrea
    Plugin Author

    Hi Loïc,

    You mean the code in #10315? Yes, it works in functions.php too.

    The same feature is not available with shortcodes though.

    #10692 Reply
    BeeNC
    Guest

    Thanks for your answer.
    Unfortunately, I can’t make it work…

    #10700 Reply
    andrea
    Plugin Author

    Hi Loïc,

    If you wish, I can take a look at your test site. I’ll need a WP admin access, and you can share it privately using my Contact page.

Reply to: Random sort
My Information