🎈 Welcome to the Marketplace — Explore and discover the ecosystem around DatoCMS, and share your own work with the community!

Prevent Unpublish

A plugin to prevent unpublishing of content in DatoCMS

This is a Community Plugin! Learn how create your own plugin, or copy and remix existing ones in our documentation

Prevent Unpublish DatoCMS Plugin

This plugin prevents unpublishing of singleton models in DatoCMS unless the user's role is explicitly allowed. It uses the onBeforeItemsUnpublish event hook to intercept unpublish actions and block them for unauthorized roles.

Features

  • Blocks unpublishing of models for non-allowed roles
  • Allowlist of roles is configurable via plugin settings (comma-separated role IDs)
  • Shows an alert to the user if the action is blocked

Setup

  1. Install dependencies

    Go to the plugin directory:

    Terminal window
    cd prevent-unpublish
    pnpm install
  2. Start the development server

    Terminal window
    pnpm dev
  3. Register the plugin in DatoCMS

    • Go to your DatoCMS project > Settings > Plugins > Add new plugin
    • Use the local development URL provided by pnpm dev (usually http://localhost:5173)
  4. Configure allowed roles

    • In the plugin settings, enter a comma-separated list of role IDs in the roleIds field (e.g. 123,456,789).
    • Only users with these role IDs will be able to unpublish singleton models.

References

Development

  • The main logic is in src/main.tsx.
  • The plugin uses the DatoCMS Plugin SDK and React UI components.

For more details, see the code and comments in src/main.tsx.

Subscribe to our newsletter! 📥
One update per month. All the latest news and sneak peeks directly in your inbox.
support@datocms.com ©2025 Dato srl, all rights reserved P.IVA 06969620480