User Groups Content Restriction 01

Laying a plan for a user group based content restriction WordPress plugin.

Base content restriction framework

I’ve been playing with content restriction framework WordPress plugin and created a first extension allowing posts (any post type) to be restricted on a user role base.
That’s one way to restrict content that might satisfy some basic needs but lacks a degree of flexibility.

User groups

I’ve used the User Groups plugin a couple of times and like its simple approach to the functionality at hand: managing user groups.
Since I’ve got a project that will require users to be managed in groups and the ability to specify which groups, rather than which single users, will be able to access a certain content I will implement an extension to the content restriction framework plugin to answer that need.

User stories

Playing the high level Behavior Driven Development game I would like the plugin to implement the following scenarios:

  • As a user able to edit a restricted post type I should be able to select which user groups are able to access that post.
  • As a user able to edit a restricted post type I should be able to select any group that’s defined by the User Groups plugin as able to access or not the post.
  • As a user able to edit a restricted post type I should be able to select no group as able to access the post.
  • As a user able to edit a restricted post type I should be able to select all groups as able to access the post.
  • As a user able to edit a restricted post type I should be able to select the meta group “Not in a group” as able to access the post.
  • As a user part of a group that can access a post I should be able to see the post single.
  • As a user part of a group that can access a post I should be able to see that post in an archive.
  • As a user part of a group that cannot access a post I should not be able to see the post single.
  • As a user part of a group that cannot access a post I should not be able to see that post in an archive.
  • As a user not part of any group I should be able to see the post single for a post that’s accessible to users not in a group.
  • As a user not part of any group I should be able to see a post that’s accessible to users not in a group in an archive.
  • As a user part of two groups, given that a group can access a post and the other can not, I should be able to see the post single.
  • As a user part of two groups, given that a group can access a post and the other can not, I should be able to see that post in an archive.

I’ve probably forgotten some cases but that’s enough to get me started.
I will leverage WP Browser and function-mocker for the BDD and unit testing work and will post my daily efforts; it should not take that long to develop (I’m connecting pieces here) and I will share what discoveries and “gotchas” I make along the way.