You are here

function privatemsg_privatemsg_name_lookup in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg.module \privatemsg_privatemsg_name_lookup()
  2. 7.2 privatemsg.module \privatemsg_privatemsg_name_lookup()

Implements hook_privatemsg_name_lookup().

File

./privatemsg.module, line 1014
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,
      );
    }
  }
}