[Resolved] Define a maximum number of items for a custom multiple field (variable per role)
This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Languages: English (English )Spanish (Español )French (Français )
Timezone: Pacific/Niue (GMT-11:00)
Hello
You wrote: "...Lets say I need to limit the quantity of repeated items for that field, depending on the current user's role?...
I need a bit more information to be able to find the right solution for you. But the general approach would require custom coding. You would need some logic to (a) limit the instances displayed or created. And (b) you would need custom code to retrieve the current user role.
Finally, you would need to (c) wrap these 2 bits of logic with conditional output
1. Clarifications on the requirements
1.1 Update or Display?
Do you mean to limit the items that are displayed? Or the number of items that are permitted to be added/uploaded?
1.2. Toolset Form or Backend Admin?
Would the update be done via a Toolset Form or do you envision the post type being updated in the backend admin screen?
2. Links of interest - where to start for logic pieces (a), (b) and (c)
you're right, I should have added some more info. Here goes:
1.1 Update or Display?
I meant to limit the number of items that are permitted to be added/uploaded.
1.2. Toolset Form or Backend Admin?
Backend Admin.
The idea I get from your links of interest is that it's easier to do this this if I use Toolset CRED Forms instead of trying to alter the Backend admin behaviour - is that correct?
Languages: English (English )Spanish (Español )French (Français )
Timezone: Pacific/Niue (GMT-11:00)
As with anything, I guess "it depends". = )
I also found tickets on our forum where you can hide the custom fields based on user role with Access. Which also looks somewhat straightforward until you think: no, I don´t want to hide the fields, I just want to disable them for input. https://toolset.com/forums/topic/hiding-fields-form-edit-based-on-roles/
It is true, however, that using a FORM might give you more control and flexibility in what you can do.
I've used Access control to fields,
but in this case hiding or disabling would not be a solution, as what I want is to let roleA add the maximum of 3 items, roleB add up to 5 and so on...
But I'll keep the FORM option in mind as probably being the best for this.