Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have many users on my website, out of some has status "elite". I am saving this status in meta key/value for each user ('meta_key' => 'elite_member', 'meta_value' => '1').

I want to display randomly 2 user profiles in rotation on my site home page which has status "elite" so that each user profiles will appear same no. of times in rotation. I am able to get all the users with meta_key "elite" and meta_value="1"

$elite_members=get_users(array('meta_key' => 'elite_member', 'meta_value' => '1'));

But I am not able to get how to display 2 user profiles in rotation so that each user will get same no. of chance to appear on home page.

share|improve this question

1 Answer 1

As get_users does not support the order_by random, you could shuffle the array after calling the function.

If you want to distribute it even, you could make another meta_value, where you store the number of appearances per user, and call the get_users with this new meta_key in ascending sort_order - this way the user with the least appearances will be shown on the homepage.

share|improve this answer
    
could u pls write example of how to call get_users with new meta_key in ascending sort_order? I am not able to do that after looking the get_users parameters.Thanks –  Pritesh Gupta Nov 28 '12 at 8:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.