bjrdesign
bjrdesign

Reputation: 142

Display Users and user url's in wordpress

I need some help I have the iteration working for listing the wordpress users however I also want to wrap their names in links and can't seem to get the user url to work... Nothing is returned to me.

Here is what I have so far.... You will see that I am trying to pull in the user_url however it just returns as nothing. Any help would be great! Thanks

<?php
  $blogusers = get_users( 
    array( 
     'role' => 'subscriber',
     'fields' => 'all' 
  ) 
);

echo '<ul>'; 
foreach ( $blogusers as $user ) {
   echo '<li><a href="' . $user->user_url  . '">' . $user->display_name . '</a>';
}
echo '</ul>'
?>

Upvotes: 0

Views: 2177

Answers (2)

code1x1.de
code1x1.de

Reputation: 304

You can get Usercount from the Database like this:

<?php
$user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" );
echo "<p>User count is {$user_count}</p>";
?>

So the Query to get all Users should be that:

<?php
$users = $wpdb->get_var( "SELECT * FROM $wpdb->users" );
echo $users;
?>

Heres the Reference: http://codex.wordpress.org/Function_Reference/wpdb_Class#General_Syntax Hopefully this was helpful ;-)

Upvotes: 0

maiorano84
maiorano84

Reputation: 11951

http://codex.wordpress.org/Function_Reference/get_author_posts_url

<a href="<?php echo get_author_posts_url($user->ID); ?>"><?php $user->display_name; ?></a>

Upvotes: 2

Related Questions