Is this code true or not

Best way to find if a code works or not is to actually try it 😉 On the face of it, it doesn’t look like you are trying to handle storing the user ids in an array or any serialized way at all.

When is a user’s meta data table loaded?

This page gives you a typical wordpress load http://codex.wordpress.org/Plugin_API/Action_Reference You can see, the current user is available after the theme is setup but before init. If you are calling these functions within the theme then you will be fine. Otherwise make sure any functions that reference the current user are called using hooks that run … Read more

Plugin will sort users by usermeta

If you want best practices of the options you listed use the user meta table. Adding a column to the users table would be the worst thing you could do – messing with table structure of default WP tables is a no-no. The other two options would fall somewhere in between – with adding your … Read more

Multiple meta values for one meta key

If multiple entries are stored in a single meta key, then get_post_meta() will return an array of those values. get_post_meta( $post_id, ‘game’ ); // returns [‘game 1’, ‘game 2′] If you want to iterate through the collection, then you’ll just use a for-loop in PHP: $games = get_post_meta( $post_id, ‘game’ ); foreach( $games as $game … Read more

List users by meta_key and meta_value

What about putting the city/regions/whatever into an array you can loop through? Something like this: $cities = array( ‘Richmond’, ‘Chicago’, ‘New York’ ); foreach ( $cities as $city ) { ?> <h2><?php echo $city; ?></h2> <ul><?php foreach ( get_users_by_meta_data( ‘school_division’, $city ) as $user ) { ?> <li><?php echo $user->first_name; ?> <?php echo $user->last_name; ?></li> … Read more

get_user_meta returning empty when it’s NOT empty

I can confidently say that it is empty at the point at which your code checks the variable. The three possibilities are: $user_id is not set or is set to an incorrect value. As you don’t show the code that sets this value, I can’t tell. You are using the wrong key. Something is hooked … Read more