View to display user points and the reason for the points Using user points module, the users of my site are successfully being assigned points for any content they post or revisions they make and so on. Now when a user logs in, i want the user to be able to see his points and the reason for the points being assigned. The view output would be something like this:


1.Blog Pic A, Blog Title A, Blog TeaserA  (and then)  Points

2.Blog Pic B, Blog Title B, Blog TeaserB  (and then)                     Points


Here then user gets points for their blog uploads. How can i create a view showing the above result. I tried but was not successful. I created a view of user points with Contextual filter  Userpoints Transactions: User and fields as  Userpoints Transactions: Points (Points) . However i am not getting any fields as content:body and so on. I understand i have to add a relationship but i am a bit confused here. I tried adding the relationship  Userpoints Transactions: Entity ID  but the  i get an error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'userpoints_txn.nid' in 'on clause'. What is this. How can i create the view for the above shown usecase. It seems a simple solution. What am i missing?

Edit: I tried different views but none are showing what i need. Would appreciate if someone can export a view, or at least, and preferable, guide me so that i also understand where i am going wrong.
I have userpoints active on one of my sites, and the display you are looking for is integrated with the module.

Look at the user account, there should be a tab (Points) (/user/$uid/points).

To create your own page, introduce a required relationship to the users table, then a contextual filter using that relationship on user:uid. When the configuration screen comes up, under 'When the filter is not in the URL' provide a default value > UID from currently logged in user. This should get your view working.

Note: The relationship must be created first, then it is available for the contextual filter.



Edit: Step by step.


Add new view: (/admin/structure/views/add)

In the 'Add View' screen, enter view name, and choose to Show 'Userpoints Transactions' of type 'all'. I chose a Table format to show fields. The rest is adjustable later.

Click 'Continue and Edit' to go to the edit screen.
Add a relationship for 'Userpoints Transactions:User'. Check 'Required' and 'Apply all displays'. This will bring the users table into the view.
Create a contextual filter on 'users:uid' using the relationship you just created. Configure the default value provided as 'UID from logged in user', and Apply.
Add whatever fields you wish and format the view.


This is the export:

$view = new view();
$view-&gt;name = 'users_points';
$view-&gt;description = '';
$view-&gt;tag = 'default';
$view-&gt;base_table = 'userpoints_txn';
$view-&gt;human_name = 'Users Points';
$view-&gt;core = 7;
$view-&gt;api_version = '3.0';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view-&gt;new_display('default', 'Master', 'default');
$handler-&gt;display-&gt;display_options['title'] = 'Users Points';
$handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
$handler-&gt;display-&gt;display_options['access']['type'] = 'none';
$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
$handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
$handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
$handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
$handler-&gt;display-&gt;display_options['style_plugin'] = 'table';
/* Relationship: Userpoints Transactions: User */
$handler-&gt;display-&gt;display_options['relationships']['uid']['id'] = 'uid';
$handler-&gt;display-&gt;display_options['relationships']['uid']['table'] = 'userpoints_txn';
$handler-&gt;display-&gt;display_options['relationships']['uid']['field'] = 'uid';
$handler-&gt;display-&gt;display_options['relationships']['uid']['required'] = TRUE;
/* Field: User: Name */
$handler-&gt;display-&gt;display_options['fields']['name']['id'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['table'] = 'users';
$handler-&gt;display-&gt;display_options['fields']['name']['field'] = 'name';
$handler-&gt;display-&gt;display_options['fields']['name']['relationship'] = 'uid';
/* Field: Userpoints Transactions: Description */
$handler-&gt;display-&gt;display_options['fields']['description']['id'] = 'description';
$handler-&gt;display-&gt;display_options['fields']['description']['table'] = 'userpoints_txn';
$handler-&gt;display-&gt;display_options['fields']['description']['field'] = 'description';
/* Field: Userpoints Transactions: Points */
$handler-&gt;display-&gt;display_options['fields']['points']['id'] = 'points';
$handler-&gt;display-&gt;display_options['fields']['points']['table'] = 'userpoints_txn';
$handler-&gt;display-&gt;display_options['fields']['points']['field'] = 'points';
/* Contextual filter: User: Uid */
$handler-&gt;display-&gt;display_options['arguments']['uid']['id'] = 'uid';
$handler-&gt;display-&gt;display_options['arguments']['uid']['table'] = 'users';
$handler-&gt;display-&gt;display_options['arguments']['uid']['field'] = 'uid';
$handler-&gt;display-&gt;display_options['arguments']['uid']['relationship'] = 'uid';
$handler-&gt;display-&gt;display_options['arguments']['uid']['default_action'] = 'default';
$handler-&gt;display-&gt;display_options['arguments']['uid']['default_argument_type'] = 'current_user';
$handler-&gt;display-&gt;display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler-&gt;display-&gt;display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler-&gt;display-&gt;display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';

/* Display: Page */
$handler = $view-&gt;new_display('page', 'Page', 'page');
$handler-&gt;display-&gt;display_options['defaults']['hide_admin_links'] = FALSE;
$handler-&gt;display-&gt;display_options['path'] = 'users-points';

/* Display: Block */
$handler = $view-&gt;new_display('block', 'Block', 'block');
$handler-&gt;display-&gt;display_options['defaults']['hide_admin_links'] = FALSE;
$handler-&gt;display-&gt;display_options['defaults']['pager'] = FALSE;
$handler-&gt;display-&gt;display_options['pager']['type'] = 'some';
$handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '5';




Second Edit:

The descriptions shown in the screen print you showed me are not stored in the database, but are generated on the fly when the page is requested.

Here is how you complete the view.

First, install and activate the Views PHP module.

Second, go into userpoints.views.inc and change 'field' =&gt; 'nid'; on line 435 to 'base field' =&gt; 'nid';. Then insert the following code after line 466:

$data['userpoints_txn']['txn_id'] = array(
      'title' =&gt; t('Transaction ID'),
      'help' =&gt; t('The transaction ID for the points allocation.'),
      'field' =&gt; array(
          'handler' =&gt; 'views_handler_field',
      ),
      'filter' =&gt; array(
          'handler' =&gt; 'views_handler_filter_string',
      ),
      'sort' =&gt; array(
          'handler' =&gt; 'views_handler_sort',
      ),
  );


This will make the Transaction ID accessible to views. (The necessary changes are included in a patch file linked at the end of this answer.)

Save your view in its current form to clear its temporary cache, then go to /admin/config/development/performance and clear your caches.

Return to your view, and add 'Userpoints Transactions:Transaction ID' as a field, and set it as excluded from the display.

Then add another field. In the 'Add Field' screen, filter on Global, and select 'Global:PHP'.

To configure the field, Create a label of your choosing, and in the Output box add the following:

&lt;?php
$transaction = userpoints_transaction_load($row-&gt;txn_id);
$value = userpoints_create_description($transaction);
echo $value;
?&gt;


Note: Do not place anything in the Value box! It is used for another purpose.

Save your view, and you are good to go.

BTW. The changes necessary in userpoints.views.inc are in a patch attached to the Features Request issue I opened on D.O.