Realname does not appear as a views filter for Users

Created on 11 May 2018, about 6 years ago
Updated 2 March 2023, over 1 year ago

I am trying to add a filter for RealName that is exposed and allows people to do partial searching of accounts by their realname.

I found that the View was not showing me a field or filter for Realname (Drupal 8.5.x).

Upon inspecting the realname.views.inc file, it looks like it still had older D7 references in it. When I updated the file to this (the join table and id needed updating), I had a filter in my View and it works:

<?php

/**
 * @file
 * Views integration for the realname module.
 */

/**
 * Implements hook_views_data().
 */
function realname_views_data() {
  $data['realname']['table']['group'] = t('Realname');
  $data['realname']['table']['join'] = [
    'users_field_data' => [
      'left_field' => 'uid',
      'field' => 'uid',
    ],
  ];

  $data['realname']['realname'] = [
    'title' => t('Real name'),
    'help' => t("The user's real name."),
    'field' => [
      'id' => 'standard',
      'click sortable' => TRUE,
    ],
    'sort' => [
      'id' => 'standard',
    ],
    'argument' => [
      'id' => 'string',
    ],
    'filter' => [
      'id' => 'string',
      'title' => t('Name'),
      'help' => t("The user's real name. This filter does not check if the user exists and allows partial matching. Does not utilize autocomplete."),
    ],
  ];

  return $data;
}

I am not 100% on the sort one, but the rest seem to work.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinquillen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024