Join User Profile fields with custom View type In Drupal 6, I've created a custom View type that allows me to query data in my custom table. One of my fields, uid, relates to drupal users.  In the Views I create for my custom type, I can display user info for each record by using a simple join in hook_views_data():

$data['users']['table']['join']['awesome_user_submissions'] = array(  
  'left_field' =&gt; 'uid',
  'field' =&gt; 'uid',
);


Now, I'd also like to display Profile fields in my view (eg: profile_first_name). Unfortunately, it doesn't appear that this will be a simple table join. How can I do this?



Solution: (thanks @googletorp)

Don't use the join I originally used (above).  Instead replace it with the following in hook_views_data(), then I can use fields from the 'users' table, as well as from the 'profile_' tables.

$data['awesome_user_submissions']['uid'] = array(
    'title' =&gt; t('User'),
    'help' =&gt; t('Relate an awesome submission to the user who entered it.'),
    'relationship' =&gt; array(
      'handler' =&gt; 'views_handler_relationship',
      'base' =&gt; 'users',
      'base field' =&gt; 'uid',
      'label' =&gt; t('user'),
    ),
  );
Views itself makes a join to the uid, so if you add the Users uid as a relationship, you should be able to get the profile fields as well.

Alternatively you could join the profile field table yourself.

For reference this is how Views makes the profile -> user join:

$data['profile_values']['table']['group']  = t('Profile');

$data['profile_values']['table']['join'] = array(
  // The node table
  'node' =&gt; array(
    'left_table' =&gt; 'profile_values',
    'left_field' =&gt; 'uid',
    'field' =&gt; 'uid',
  ),
  // The users table
  'users' =&gt; array(
    'left_table' =&gt; 'profile_values',
    'left_field' =&gt; 'uid',
    'field' =&gt; 'uid',
  ),
);