3

Do I need to use hook_views_data like a custom table?

3
  • 1
    not sure what you mean by $user->data. Anyhow, have you tried creating a User view?
    – No Sssweat
    Commented May 2, 2017 at 23:28
  • 1
    FYI I want a table of users with their topic of preference that is stored in the users table with $user->data['topic'].
    – Tabestan
    Commented May 2, 2017 at 23:29
  • The data property on the user object is a serialized field. It's not great to store things there, but it would be possible to code a views field handler that gets that data and outputs it in a meaningful way. There may already be one in contrib.
    – mradcliffe
    Commented May 3, 2017 at 1:52

2 Answers 2

4

Actually, this can be done within the Views UI by selecting the user:data field and then choosing a key.

1
  • It only works if the data is not serialized, or have I overseen an option to output serialized user data in views?
    – Elin Y.
    Commented Feb 19, 2020 at 15:24
-1

You need to first add relationship with 'author' in the view and accordingly you will get the user data fields which you can use in your fields as well as in filters.

Not the answer you're looking for? Browse other questions tagged or ask your own question.