So, I'm designing a website (who isn't?) and I created the basic framework for a users page from a tutorial I found. Using some previous knowledge I managed to make it display a few custom fields that are defined by the user. Everything works fine as is, but now I want to do a few things to it that I have not the slightest clue how to even begin...
Here is my user page code so far... and oh yes I'm using WordPress which is why I made it check manually for page status in my Page.php file.
<?php
if ( is_page('Users'))
{
echo "<ul id=\"UsersList\">";
/*
First we set how we'll want to sort the user list. You could sort them by:
------------------------
* ID - User ID number.
* user_login - User Login name.
* user_nicename - User Nice name ( nice version of login name ).
* user_email - User Email Address.
* user_url - User Website URL.
* user_registered - User Registration date.
*/
$szSort = "user_nicename";
/*
Now we build the custom query to get the ID of the users.
*/
$aUsersID = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $szSort ));
/*
Once we have the IDs we loop through them with a Foreach statement.
*/
foreach ( $aUsersID as $iUserID ) :
/*
We use get_userdata() function with each ID.
*/
$user = get_userdata( $iUserID );
/*
Here we finally print the details wanted.
Check the description of the database tables linked above to see
all the fields you can retrieve.
To echo a property simply call it with $user->name_of_the_column.
*/
if($user->user_login != "Unknown") // don't show the placeholder for [unknown] author
{
echo '<a href="">' . get_avatar( $iUserID, $size = '45', $border='0') . '</a>';
echo '<li>' . ucwords( strtolower( $user->user_login ) ) . '</li>';
if($user->favorite_player != "")
{
echo '<li>' . $user->favorite_player . '</li>';
}
if($user->player_name != "")
{
echo '<li>' . $user->player_name . '</li>';
}
}
/*
The strtolower and ucwords part is to be sure
the full names will all be capitalized.
*/
endforeach; // end the users loop.
echo "</ul>";
};
?>
Problem one: This does NOT sort my name, despite the tutorial's insistence that it will. I have not even a guess as to why this is.
Problem two: I would like to either sort this list into two columns or paginate it or both but I am not sure how to do either.
Problem three: I want to insert some static text between the echo '<li>' and the . $user->player_name . '</li>'; so that it reads:
o Player Name: USER'S VARIABLE ' PLAYER NAME' HERE
Yes that 'o' is supposed to be the list item dot. I know how strings work, I just can't get my attempts to work out syntax-wise.
Any help would be greatly appreciated! Tutorials, answers, suggestions, examples, anything. The extent of my previous coding knowledge is several years of UnrealScript, so you can see why this simple thing is baffling me. Frankly I'm surprised this much of it works.