Can I create a role that only shows records created by this author?

I’m creating a CMS for a franchise business (estate agents) where each of the franchises will manage their own content. The content types are similar across all the franchises and there is only one instance of Strapi. This is important as the website should show the content from all the franchises in one website with only 1 API call. A franchise would have a role that when logged in to the admin panel would only see records created by that user. This is important as franchises should not see and edit the records published by other franchises. In this instance I can have a single user account per franchise.

Is this something I can achieve out the box with Strapi or would this require some custom development? I can’t find anything on this in the docs on roles.

Hi @codycustard,
This is not something you can achieve with Strapi Out of the box, but will require some custom development.

You can try implementing an is owner policy as described in the docs:
Is owner policy docs

It adds a relation from content to user to know who the author of the content is.
When this relation is established in the database you can refuse anybody from editing the content if they are not the author.

Can you also prevent them from being visible in the admin panel?

This is not natively possible in Strapi, but with some customization you are able to hide certain pieces of content in the Admin panel.

You would have to extend the content-manager plugin and alter the find controller in the /controllers/collection-types.js file. The file on github.

To extend the content-manager plugin follow this guide: Strapi plugin customization.

If you have implemented the is owner policy, and have extended the collection-types.js file you can filter the results in the find controller to only show the items of which the requesting user is the author.

You could do something like this:

// File /extensions/content-manager/controllers/collection-types.js
// ...

results.filter((result) => {
  if (result.author) {
    return result.author.id === ctx.state.user.id;
  } else {
    return true;
  }
});

// ...

Now you will only see the items in the admin panel of which you are the author.

Make sure to make an exception for the admin user :stuck_out_tongue:.
The admin should be able to see all the content, all the time.

if you had this kind of functionality working you would be able to do things like build this forum using strappy and much more. lol