• 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)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sorting User Lists by Register Plus Fields’ is closed to new replies.