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.

Alright, so here's my current code (which works, displaying the users in order by ID and excluding the admin user):

$site_admin = "1";
$order = 'ID';
$user_ids = $wpdb->get_col("SELECT ID FROM $wpdb->usermeta WHERE ID != '$site_admin' ORDER BY $order"); // query users
foreach($user_ids as $user_id) : // start authors' profile "loop"
    $user = get_userdata($user_id);

    $level = $user->user_level;
    if ($level > 0) 
    { ?>

    ((information to display goes here))

   <?php  } ?>

What I'd like to do is add a meta field (I believe that's the right terminology, but please correct if wrong), and I have already added that, then type in a number for each author.

Here's how that was added (in functions.php):

<?php function my_new_contactmethods( $contactmethods ) {
$contactmethods['order'] = 'Order on the About Page'; 
return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);?>

Last, I'd like to display the users in that order.

There are a number of related questions, but none that I could find that order the users by fields which are added in addition to the typical Wordpress user information (e.g. ID, user_nicename, etc.) I can simply replace "ID" in the code above with "user_nicename" and that works fine, but I need to be able to manually set the order of each of the users, so none of the built-in fields will work for that purpose.

share|improve this question
    
Is this question about adding a field to the user profile, or listing users by that field? Note that we have a 1 question per question policy –  Tom J Nowell Aug 29 at 12:15

1 Answer 1

You can use the default function get_users(), and then re order the result by the meta id. Here is the answer

share|improve this answer
    
Well, I'm already ordering them by ID; I'm hoping to order them by something else – however, I might be able to adapt something here, so thanks! –  Jon Schroeder Aug 17 '12 at 18:59

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.