Ordering in Kaf's all authors template (1 post)

  1. oveh
    Posted 7 years ago #

    Hi, im using Kaf's all authors template (http://guff.szub.net/source/page-authors-2.0.php) to display a list of the users on the site and it works almost perfectly. The one thing i cant figured out is how i can order the users the way i want it.

        global $wpdb, $table_prefix; // set global WP vars needed for script
        $order = 'user_nicename'; // set order for users table query
        $user_ids = $wpdb->get_col("SELECT ID FROM $wpdb->users ORDER BY $order"); // query users
        foreach($user_ids as $user_id) : // start authors' profile "loop"
        $user = get_userdata($user_id); // retrieve author (i.e. user) details
        $level = $table_prefix . 'user_level'; // set 'user_level' usermeta meta_key record
        $user->user_level = $user->$level; // assign 'user_level' property to $users
        $role = $table_prefix . 'capabilities'; // set 'role' usermeta table meta_key record
        $user->role = array_keys($user->$role); // assign 'role' property to $user
        $user->role = $user->role[0]; // make sure $user->role is not an array

    Now its order by user_nicename, what i want is a specific ordering. So i created a extra user field with the Cimy User Extra Fields plugin (http://www.cimatti.it/blog/cimy-wordpress-plugins/cimy-user-extra-fields/)

    I gave every user a special number by creating a Order field. But i cant get the all authors template to sort after those numbers.

    I tried something like this:
    $order = get_cimyFieldValue($user_id, 'ORDER');

    which gives me:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
    Warning: Invalid argument supplied for foreach() in /hsphere/local/home/tohin406/tohinvest.no/wp-content/themes/ovelove/page-medlemmer2.php on line 20

    im a php newbie so this error dont help me much. Anybody out there who can help?

    Kindly Regards,

Topic Closed

This topic has been closed to new replies.

About this Topic