Hi guys, I’m considering getting the AFC Pro to be able to use the repeater field. I’ve used the repeater fields years ago in a now defunct website and loved every bit of it. And I’m thinking it could be of use in a new implementation, but I don’t know if this is possible.
I need to create a log of sorts via a post where several users can input data over time. Say, the first user creates a post, fills in the required data via AFC fields and publishes it. Some time later, the second user comes back, edits the post to log new data (and this may happen several times over, that’s where the repeater would work like a charm). But I don’t want the second user to be able to delete any prevous data that was saved to the post. In fact, I don’t want any user to be able to, not even the original one. I want all previously added data to be locked unless you’re and admin.
All the user privileges can be managed elsewhere, if course I’m not expecting ACF to have this behaviour shipped by default, but have any of you come across this scenario? Is there a way of creating a function that allows users to add fields to a post, but not delete previous ones?
I’ve searched all over the interwebs, to no avail.
Thanks for reading this! Have a good day
I have done something similar in the past. On one client site I have an options page with several repeaters. The client can add new rows, and they can reorder the existing rows but they cannot delete or edit existing rows.
Actually, it’s a little more complicated because the rows created are used to dynamically populate a select field that is used on a specific CPT. They are not allowed to delete a value after that value has been used on a post. So when the options page is loaded a check is done of each value to see if it has been used.
So, yes this can be done, but it requires JS. Using JS you can also remove the ability to change the order of rows as well.
This is not a perfect solution because anyone that knows there way around well enough could get past it if they really wanted to.
This could also be done by creating a field for inputting new data and then creating an acf/save_post action that takes the content in these fields and adds them to the repeater so that the repeater is not actually where the content is added thus removing the need to show the repeater to users in the first place and this would remove the ability to bypass the JS solution.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.