title: Assigning post-specific roles to users in WordPress
body: <p>I am designing a plugin that need to assign users to a particular post (of a custom type).</p>
  
  <p>For instance, I have a custom post type: <code>ClassifiedFile</code></p>
  
  <p>For posts of that type, I will need somewhere in the interface to assign users to it, each having different capabilities. In that case, that could be: </p>
  
  <ul>
  <li><code>Reviewers</code> assigned to a particular classified file can read it and mark it as approved</li>
  <li><code>Readers</code> assigned to a particular classified file can only read it</li>
  <li>Or course, readers and reviewers do not have access to other classified files than the ones they are allowed to see.</li>
  <li><code>Managers</code> who can assign <code>Reviewers</code> and <code>Readers</code> to classified files</li>
  <li><code>PluginAdmin</code> who can assign <code>Managers</code> to classified files</li>
  </ul>
  
  <p>Ideally, the solution should lend to efficient requests of the type:</p>
  
  <ul>
  <li>I want to list all classified files a user can read (be it as reviewer or as reader).</li>
  </ul>
  
  <p>So far :</p>
  
  <ul>
  <li>I have stored a few particular properties in the meta data of the post (such as the approval status). </li>
  <li>I have created custom capabilities : "plugin-admin", "manage-file-users", "approve-file" and "read-file" </li>
  <li>I provide two custom roles for that : File Group Manager ("plugin-admin"), File Group Manager ("manage-users") , File Reviewer ("approve-file", "read-file") and File Reader ("read-file")</li>
  </ul>
  
  <p>I must say I am struggling to find a nice way to address the listing and storing of priviledges per classified file. Ideally I'd like to avoid having to create a separate DB table but if that is the way to do it then I'll do that.</p>