Allow/restrict access based on privacy setting flags in profile I have privacy profile type and flags with checkbox like "Keep all my friends private" and "Keep all my videos and channels private".These are in my privacy settings profile.Now i want  to allow or restrict the access based on my flagging (on/off checkbox) for the users.Here i have two content types videos &amp; channels.By default other users can watch my videos &amp; channels and i want to make it private when i click my checkbox on for "Keep all my videos and channels private" and once i uncheck this,it should become public.The same need to be done for "Keep all my friends private".I have used user relationship module for friends.How can i do this? Is it possible using php coding or is there any other solution.Please help.
Thank you.
Implement hook_node_access($node, $op, $account) and check whether the user has flagged his content to be private, if so then deny access.

function MYMODULE_node_access($node, $op, $account){
  global $user;

  if($node-&gt;uid != $user-&gt;uid &amp;&amp; $node-&gt;type=='video' &amp;&amp; $op=='view'){
     $entity_type = 'profile2';
     $profile = profile2_load_by_user($node-&gt;uid,'main');

     $flagging_data = flag_get_user_flags($entity_type, $profile-&gt;pid ,$node-&gt;uid);

     /************ UPDATED ****************/
     if(isset($flagging_data['channels'])){
          return NODE_ACCESS_DENY;
     }
  }
}