Create a custom filter in Views related to a custom table I have a table where I keep some logs, for example, when a user visits a node, I record of the form:

The user 34 visited node 235.


Then I have a Views what show me the following fields:


NID
Title
Body


How to display only the nodes that the current user has visited or not?

EDIT:

Example of my custom table:

------------------------------------------------------
| UID | action                        | IP           |
------------------------------------------------------
| 34  | The user 34 visited node 235. | 200.54.21.24 |
------------------------------------------------------


UID = User ID
I would do the following to achieve this. In the custom table where you maintain log create a view handler using hook_views_data. Add the following code in your .module file

     function MODULENAME_views_api() {
       return array(
           'api' =&gt; '3.0-alpha1',
           'path' =&gt; drupal_get_path('module','MODULENAME'). '/views',
       );
    }

Then add a file with the name MODULENAME.views.inc in your module views folder and the following code.

    /**
 * Implements hook_views_data()
 *
 */
function MODULENAME_views_data() {

 $table = array(
    'custom-table-name' =&gt; array(  //  Custom table
       'table' =&gt; array(
          'group' =&gt; 'Custom Tables',      // Groupname
             'base' =&gt; array(
               'field' =&gt; 'id',  //Primary key
               'title' =&gt; '&lt;your table name&gt;',
            )
        ),
     //Description of id
        'id' =&gt; array(  
           'title' =&gt; t(' Id'),
           'help' =&gt; t(' Id field'),
           // is mydons_custom_id field sortable TRUE
           'field' =&gt; array(
              'click sortable' =&gt; TRUE,  
            ),
      //Filter handler for filtering records by mydons_custom_id     
           'filter' =&gt; array(
               'handler' =&gt; 'views_handler_filter_numeric'   
            ),  

           'sort' =&gt; array(
              'handler' =&gt; 'views_handler_sort'       
           )
         ),

         'user_id' =&gt; array(      
           'title' =&gt; t('User ID'),
           'help' =&gt; t('User ID referring to User for users table'),
           'field' =&gt; array(
              'click sortable' =&gt; TRUE,
           ),
           'filter' =&gt; array(
              'handler' =&gt; 'views_handler_filter_string'
           ),

           'sort' =&gt; array(
              'handler' =&gt; 'views_handler_sort'
           ),
           'relationship' =&gt; array(
            'base' =&gt; 'users', // The name of the table to join with.
            'base field' =&gt; 'uid', // The name of the field on the joined table.
            'relationship field' =&gt; 'user_id',
            // 'field' =&gt; 'nid' -- see hook_views_data_alter(); not needed here.
            'handler' =&gt; 'views_handler_relationship',
            'label' =&gt; t('User'),
            'title' =&gt; t('Referenced USER entity'),
            'help' =&gt; t('Add USER Fields'),
          ),

        ),

         'node_id' =&gt; array(      
           'title' =&gt; t('Node ID'),
           'help' =&gt; t('Node ID referring to Node'),
           'field' =&gt; array(
              'click sortable' =&gt; TRUE,
           ),
           'filter' =&gt; array(
              'handler' =&gt; 'views_handler_filter_string'
           ),

           'sort' =&gt; array(
              'handler' =&gt; 'views_handler_sort'
           ),
           'relationship' =&gt; array(
            'base' =&gt; 'node', // The name of the table to join with.
            'base field' =&gt; 'nid', // The name of the field on the joined table.
            'relationship field' =&gt; 'node_id',
            // 'field' =&gt; 'nid' -- see hook_views_data_alter(); not needed here.
            'handler' =&gt; 'views_handler_relationship',
            'label' =&gt; t('User'),
            'title' =&gt; t('Referenced USER entity'),
            'help' =&gt; t('Add USER Fields'),
          ),

        ),





      )
    );
    return $table;
}


Clear the cache and go to views page and create another view of your custom table. Add relationship to your node and users and contextual filters to show logged in users node.