Find user

Component ID

194219

Component name

Find user

Component type

module

Development status

Component security advisory coverage

not-covered

Downloads

2617

Component created

Component changed

Component body

This is a custom search module for users. It provides a search page that can search for users by username, email, or a custom text field. The custom text field can come from any content type, thus this module plays nicely with any user-as-node strategy.

The module does one thing and does it well, and is independent of search module. It has enough customization options to allow you to bend it to your will, as well as a healthy number of themable functions.

On the administer settings page for the Find user module you have the chance to set many configuration options. If you have CCK enabled and have added any text fields to any content types, these fields will show up as options to be searched. This allows you to use a module like nodeprofile or usernode or bio to extend your user profile and make it searchable via the Find user module.

The finduser module adds a menu item which links to the page with the search form. Users need the access user profiles permission in order to have access to this page and the finduser functionality.

There are four theme functions to help you control the visual aspect of the find user search. Additionally you can theme the 'finduser_form' using typical FAPI form theming techniques. The most important theme function to be aware of is the theme_finduser_node function. Depending on what user-as-node module you are using, you may need to load extra information in this theme function in order to display the search results according to your taste. What you get is the $nid of the node that was found, which is intended to be a usernode or nodeprofile node. Consult the documentation of the appropriate module to see what you have to do to get to the user information you might need.

function theme_finduser_page($form, $results) {
  return $form. $results. theme('pager');
}

/**
 * This theme function themes the results for username or email searches.
 */
function theme_finduser_user($id) {
  $user = user_load(array('uid' => $id));
  return theme('username', $user);
}

/**
 * This theme function themes the results for the custom CCK field searches.
 * This is where you need to add special logic for getting from the usernode
 * to the user, depending on what type of user-as-node strategy you are using.
 */
function theme_finduser_node($id) {
  $node = node_load($id);
  return theme('node', $node, TRUE);
}

/**
 * This theme function themes the list of search results.
 */
function theme_finduser_item_list($items) {
  return theme('item_list', $items);
}

This module is maintained by toemaz.

Alternate solutions

If you are looking for a way to do keyword searches on CCK fields (a common need for those using bio, node_profile or usernode modules), you may want to check out the views_fastsearch module (for Drupal 5) or the built-in search filter for Views 2 (Drupal 6).