Views PHP Filter - Filter Results by Role I looked a lot of places and couldn't find a way to filter the results of a view based on the nodes a user could actually edit. So I used Views PHP Filter and some custom code to make it happen.

Comments and improvements welcome.

global $user;
$type = array();
$nid_list = array();
$perms = array();
foreach($user-&gt;roles as $role) {
  $role_perms = db_fetch_array(db_query("SELECT `role`.`name`, `permission`.`perm` FROM {role} INNER JOIN {permission} ON `role`.`rid` = `permission`.`rid` WHERE `role`.`name` = '%s'", $role));
  $perm_temp = explode(", ", $role_perms['perm']);
  $perms = array_merge($perms, $perm_temp);
}
foreach($perms as $perm) {
  $pos_edit = strpos($perm, "edit");
  $pos_content = strpos($perm, "content");
  $pos_products = strpos($perm, "products");
  if (($pos_edit !== false) &amp;&amp; ($pos_content !== false)) {
    $perm = substr($perm,9,strlen($perm)-16);
    if (!in_array($perm, $type)) {
      $type[] = $perm;
    }
  } else if (($pos_edit !== false) &amp;&amp; ($pos_products !== false)) {
     $perm = substr($perm,9,strlen($perm)-18);
     if (!in_array($perm, $type)) {
       $type[] = $perm;
     }
  }
}
foreach($type as $ctype) {
  $nids = db_query("SELECT `node`.`nid` FROM `node` WHERE `node`.`type` = '%s'", $ctype);
  while($row = db_fetch_array($nids)) {
    $nid_list[] = $row['nid'];
  }
}
asort($nid_list);
return $nid_list;
I would take the ORDER BY out of your last query and let views sort things itself. After all, you may want to sort the nids by date or something later on, so why do things twice?

And also change your query style to use the drupal syntax, like:

SELECT nid FROM {node}...