Drupal 7 Views, List, Filters and User I have three content types :
Content type A
Content type B
Content type C

B has a node reference to A.
C has a node reference to B.

I have also 2 roles :
Role 1
Role 2
Role 1 is belong to Content type B.
Role 2 is belong to Content type C.

I'm creating a view list in which

1) Content type A (nid) is passed from URL. Filter nodes of type B with nid of type A. ( done with contextual filter )
2) Criteria content type == B ( done with criteria )
3) Join content type C with content type B. ( done with relationship )

I have successfully got a list with above three.

But I have one more thing to do :
If logged-in user is Role 1, I want to filter nodes of type B of the logged-in user.
If logged-in user is administrator, show all nodes of type B which is filtered with node of type A.

How can I do that ? I'm using D7.7

[Edit]
I think filter criteria don't need for user role. It can be done with user filter for content type B. But I can only select all users associated the type B. I cannot select the current logged-in user id from views filter.
I may need to use this module : http://drupal.org/project/viewsphpfilter
Unfortunately, it has no update for D7.
I've done with hook_views_query_alter().

function mymodule_views_api() { // your module name into hook_views_api
    return array(
        'api' =&gt; 3,
        // might not need the line below, but in any case, the last arg is the name of your module
        'path' =&gt; drupal_get_path('module', 'mymodule'),
    );
}

function mymodule_views_query_alter(&amp;$view, &amp;$query){
    global $user;
    switch($view-&gt;name){
        case 'my_view_name' :   
            if(!in_array('administrator', $user-&gt;roles) || array_key_exists(4, $user-&gt;roles)){
                $result = db_query('my_query_here');
                $nodes = array();                   
                foreach($result as $row){
                    $nodes[] = $row-&gt;entity_id;
                }
                $query-&gt;where[0]['conditions'][] = array(
                    'field' =&gt; 'node.nid',
                    'value' =&gt; $nodes,
                    'operator' =&gt; 'in'
                );
            }
            break;
}