Views to display nodes based on ACL permission I'm trying to use Flexiaccess with ACL to build a view based on node that the user has access granted by Flexiaccess.

I found this on Drupal.org, it's the same use case, but is not working for me maybe because is for Drupal 6. (http://drupal.org/node/549412):


  
    Here's how to do it:
  
  
  Under Arguments, create a new argument: "Node: Nid"
  
  Under "Action to take if argument is not present", select "Provide
  default argument"
  
  Set the "Default argument type" to "PHP Code", and enter the
  following:
  
  global $user; return db_result(db_query("SELECT
  GROUP_CONCAT(CAST(an.nid AS CHAR) SEPARATOR ',') FROM {acl_user} au
  INNER JOIN {acl_node} an ON au.acl_id = an.acl_id WHERE an.grant_view
  = 1 AND au.uid = %d", $user->uid));
  
  Then check "Allow multiple terms per argument", and click "Update".


I follow those steps but my view shows nothing.

Any help is really appreciated.
According to: https://www.drupal.org/node/1255426, Drupal 7 does not have db_result function. You have to replace it with db_query().

Code which worked in my special case:

&lt;?php
global $user;
$query = db_query("SELECT GROUP_CONCAT(CAST(an.nid AS CHAR) SEPARATOR ',') FROM {acl_user} au INNER JOIN {acl_node} an ON au.acl_id = an.acl_id WHERE an.grant_view = 1 AND au.uid = :uid", array(':uid' =&gt; $user-&gt;uid));
$result = $query-&gt;fetchObject();
return reset($result);
?&gt;