function privatemsg_privatemsg_name_lookup

7-1 privatemsg.module privatemsg_privatemsg_name_lookup($string)
7-2 privatemsg.module privatemsg_privatemsg_name_lookup($string)
6-2 privatemsg.module privatemsg_privatemsg_name_lookup($string)

Implements hook_privatemsg_name_lookup().

File

./privatemsg.module, line 997
Allows users to send private messages to other users.

Code

function privatemsg_privatemsg_name_lookup($string) {
  // Remove optional user specifier.
  $string = trim(str_replace('[user]', '', $string));
  // Fall back to the default username lookup.
  if (!$error = module_invoke('user', 'validate_name', $string)) {
    // String is a valid username, look it up.
    if ($recipient = user_load_by_name($string)) {
      $recipient->recipient = $recipient->uid;
      $recipient->type = 'user';
      return array(privatemsg_recipient_key($recipient) => $recipient);
    }
  }
}