Tag Info

Hot answers tagged

5

I am not sure why your query is returning more IDs than necessary. The $args for get_users look correct. By default get_users does not support orderby=rand, but you can overwrite that option. See below: function random_user_query( &$query ) { $query->query_orderby = "ORDER BY RAND()"; } // Usage: [random_users how_many = 3] add_shortcode( ...


1

As noted at the codex page for get_user_meta(): NOTE If the meta value does not exist and $single is true the function will return an empty string. If $single is false an empty array is returned. So I would suggest to do the check like this: ! empty( $themeta ) Regrading your other question, you can save the array by simply doing it like ...


1

Check out get_users(): $subscriber_ids = get_users( array( 'fields' => 'ids', 'role' => 'subscriber', ) ); foreach ( $subscriber_ids as $id ) echo "$id<br />";



Only top voted, non community-wiki answers of a minimum length are eligible