Sorting User Lists by Register Plus Fields
-
I was wondering if anyone could help me?
I’ve managed to put together a script which will pull a list of users from the database, the script works fine except it wont sort the list how i want it to.The list just shows the users company name and city (from register plus plugin) and I need to sort the list in ASC order by company name, but no matter what I do it wont sort 🙁 I’m sure its something really simple but I just carn’t see it.
Here’s what im using:
<?php $szSort = "company_name";?>
<?php $aUsersID = $wpdb->get_col( $wpdb->prepare("SELECT
$wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $szSort ));
foreach ( $aUsersID as $iUserID ) :
$user = get_userdata( $iUserID ); ?>
<?php if($user->wp_user_level == 2) {
?>
<a href="<?php bloginfo('siteurl'); ?>/author/<?php echo ucwords( (
$user->user_login ) ); ?>"> <?php echo '<li>' . ucwords( (
$user->company_name ) ) . ' - '; ?></a> <?php echo '' . ucwords( (
$user->city ) ) . '</li>';
}
endforeach; // end the users loop.
?>
</ul>
<?php endwhile; endif; ?>
- The topic ‘Sorting User Lists by Register Plus Fields’ is closed to new replies.