0

I'm searching for an idea, to protect a single entry from being edited / deleted by editors (CP / backend). Of course, it's easy to do for fields or sections, but for a single entry ... hmmm ...

  • https://plugins.craftcms.com/isolate?craft4 -> that's not fitting to my needs
  • a concept could be, to manipulate the CP with CSS / JS -> looks like a dirty hack
  • maybe a custom plugin is needed -> a problem for me, unfortunalety

Any ideas? :)

1
  • Making the one entry it's own section is not an option? If not, all I could think of is a CP plug in with a hook ...
    – thomas
    Commented Sep 12, 2023 at 7:01

2 Answers 2

0

Just use a single for that entry. When you add a new single, existing users have no access by default.

Additionally, if your page must live within a structure, you can create a new page type (e.g. 'Linked entry') with a field that can select only one entry from 'singles'. In the template for your new page type takes the input from that field and use it to create a redirect to your single; which editors do not have permission to edit/delete.

Something like this:

enter image description here

4
  • Thanks for your input, Seth! But that's not working: In my case, it's a subentry inside a structure ... concrete a specific subpage of the sitemap. But I want to be sure, that this subpage will not be deleted by mistake by any editor.
    – Marc
    Commented Sep 12, 2023 at 14:22
  • Does it really have to be in a structure though? You could set up the single URL to appear as though it belonged in the structure; and was included in the site map accordingly. E.g: /about/press-releases/not-really-a-press-release could just be a single; an uneditable one-off Commented Sep 12, 2023 at 16:32
  • Yes ... because the editors are free to add / edit / remove subpages of this entry. I just want to protect this parent entry, because this entry id and position in the pagetree is important. It's a kind of "folder" ... not a page.
    – Marc
    Commented Sep 14, 2023 at 7:55
  • The concept to remove functionality in control panel with css / js is not too bad ... but it still is a dirty workaround and I'm missing a state of the art concept for this usecase in Craft.
    – Marc
    Commented Sep 14, 2023 at 7:57
0

Without using singles, you'll need to write a module to add this functionality.

I'd recommend adding a new field to the section called "User Allow List" (or "Deny List" you can go either way with this).

Add an on-event function that checks the users in this field and sends a 403 if the current user does not match.

Add an on-save function for entries in this section that auto-populates your default list of Users. Now that I've typed this far.... best to do this by User Group and not individual Users. Have the field be a dropdown and not a User selection field, have the values match the ID or slug of the user group and check against that group.

Then you can add/remove users from that access list to manage it.

(you could also browse the plugin marketplace, I havent looked but maybe someone has published something like this already)

2
  • 1
    Ok, thx for you comment, Cherry! This'll be my challenge to write my first module ... but you gave me a concept at least. :)
    – Marc
    Commented Sep 25, 2023 at 11:59
  • Best of luck! You'll feel great once you do one ^_^
    – cherrykoda
    Commented Sep 27, 2023 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.