If the Real Name module is installed, and I'm searching for an editor to add to a section, the autocomplete field does not return results based on the user's real name (only the username).

Thankfully, it's possible to alter the query in a custom module, like so:

/**
 * Implements hook_query_TAG_alter() for "user_autocomplete" from Workbench Access.
 */
function MYMODULE_query_user_autocomplete_alter(QueryAlterableInterface $query) {
  $conditions = &$query->conditions();
  $like = $conditions[0]['value'];
  unset($conditions[0]);
  $query->leftJoin('realname', 'rn', 'u.uid = rn.uid');
  $query->condition(db_or()
    ->condition('rn.realname', $like, 'LIKE')
    ->condition('u.name', $like, 'LIKE'));
}

However, the "user_autocomplete" tag provided by Workbench Access is a little generic, and it should probably be changed to something like "workbench_access_user_autocomplete".

Still, it would be ideal if support could be added for Real Name.

Comments

joelstein created an issue. See original summary.

joelstein’s picture

Status: Active » Needs review
StatusFileSize
new1.17 KB

Here's a patch which adds Real Name support.

joelstein’s picture

Issue summary: View changes