Title: Sorting User Lists by Register Plus Fields
Last modified: August 19, 2016

---

# Sorting User Lists by Register Plus Fields

 *  [Richard B](https://wordpress.org/support/users/richard-b/)
 * (@richard-b)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/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; ?>`

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Richard B](https://wordpress.org/support/users/richard-b/)
 * (@richard-b)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/sorting-user-lists-by-register-plus-fields/#post-1216975)
 * Bump, please let me know if this is in the wrong section! Still stuck
 *  Thread Starter [Richard B](https://wordpress.org/support/users/richard-b/)
 * (@richard-b)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/sorting-user-lists-by-register-plus-fields/#post-1217018)
 * bump bump 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Sorting User Lists by Register Plus Fields’ is closed to new replies.

 * 2 replies
 * 1 participant
 * Last reply from: [Richard B](https://wordpress.org/support/users/richard-b/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/sorting-user-lists-by-register-plus-fields/#post-1217018)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
