I have a custom table (myusersession) which contains the uid field that is a reference to user entities.
How can I add user entity fields (exactly 'name') to my view?
I tried many variations of join, in hook_views_data()
, but none of them works.
$data['myusersession']['table']['join'] = array(
'users_field_data' => array(
'field' => 'uid',
'left_field' => 'uid',
),
);
$data['myusersession']['uid'] = array(
'title' => t('UID'),
'help' => t(''),
'field' => array(
'id' => 'numeric',
),
'filter' => array(
'id' => 'numeric',
),
'argument' => array(
'id' => 'numeric',
),
'relationship' => array(
'title' => t('User'),
'help' => t(''),
'base' => 'users',
'base field' => 'uid',
'id' => 'standard',
),
);
I also tested variations of the table name, such as users_field_data, users, and user.
As I understand the following code should be work, but it doesn't in my case.
'relationship' => array(
'title' => $this->t('User'),
'label' => $this->t('User'),
'base' => 'users',
'base field' => 'uid',
'relationship field' => 'uid',
),
With ['table']['join']
, the table appears as column on the view with User as base, but but if the view base is myusersession, User doesn't appear.