Drupal: user directory shows blocked users I have a simple user directory in drupal, but when I block certain user in the admin, they still show up in the directory, although clicking on the user gets you to "access denied" page for the user profile. Do I need to add something about the user status to make this work?

Here is the code:

$result = db_query('SELECT * FROM users_roles LEFT JOIN users ON users_roles.uid = users.uid left join node on users.uid = node.uid left join content_type_bio on node.vid = content_type_bio.vid WHERE users_roles.rid = 6 and node.type = "bio" ORDER BY users.name');

while ($data = db_fetch_object($result)) {
  // we're working off user names, so replace . with space and captitalize   $string = $data-&gt;name;   $pattern = '[\.]';   $replacement = ' ';   $name = preg_replace($pattern, $replacement, $string);   $name = ucwords($name);   $data-&gt;picture = 'http://example.com/' . $data-&gt;picture;   $image = $data-&gt;picture != "http://example.com/" ? theme_image($data-&gt;picture, $alt = $name, $title = $name, $attributes = array('class' =&gt;'left'), $getsize = FALSE) : theme_image('http://example.com/files/pictures/default.jpg', $alt = $name, $title = $name, $attributes = array('class' =&gt;'left'), $getsize = FALSE);
  $item[] = array('text' =&gt; $name, 'path' =&gt; 'user/'. $data-&gt;uid, 'avatar' =&gt; $image, 'title' =&gt; $data-&gt;field_occupation_value); //  $item[] = l($text = $name, $path = 'contact/'. $data-&gt;uid); //  $item[] = l($text = $name, $path = 'user/'. $data-&gt;uid .'/contact');   // this is an example of the url we're constructing   //http://example.com/user/27/contact
}
From your query and the default Block User account user settings option available to the Site Administrator per User:

Simply add into your SQL query WHERE clause the following:

and users.status &lt;&gt; 0

and this will change your user list to NOT include blocked users.