Hi @itsviney
I hope you’re well today and thank you for your question!
Currently it isn’t possible out of the box. There may be a workaround doable, using custom code snippet, but we’ll need to consult that with our developers and before doing that, let me make sure that we are on the same side:
I understand that there’ll be set of dates defined in ACF fields but:
– are those a “user fields” (as in “additional user meta”) so they should be recognized by logged-in user ID (when form is rendered) or by some post ID (if yes – where it should be taken from; e.g. post that form is embedded on)?
– the dates – should those be used as “Start/End” dates for datepicker limits settings or the “Disabled dates” (those are specific dates) or “Disabled date ranges”?
Let us know and we’ll take it to our developers to see if there’d be some custom code possible for it.
Best regards,
Adam
Hello @itsviney ,
We haven’t heard from you for several days now, so it looks like you don’t have more questions for us.
Feel free to re-open this ticket if needed.
Kind regards
Kasia
Thanks Adam. The ACF fields are on an options page so they’re effectively globals, not linked to a specific page or user.
I have it set up with a start and end date inside a repeater field so the user can enter as many closure periods as they need. ACF returns this as a nested array. If one of your Devs was able to provide an example of how this could be done I’d really appreciate it. No need to worry about specifics like the field names – I’m hoping I can get the gist and whatever snippit they provide.
Thanks 👍
Hi @itsviney
Thanks for response!
So it is doable 🙂 I gave it a go and came up with this code:
https://gist.github.com/adczk/e72fc7d55de43978152ff32757ad59b1
It should be added to the site as MU plugin and there are two requirements:
1. in this line
$allowed_fields = array( 'date-1' );
you need to define IDs of datepicker fields which should be affected; since it’s an array, you simply separate them with commas if there’s more than one; note: it’s not aware of the form ID
2. you must make sure that the format of date set in datepicker field in Forminator and set as “return format” in ACF date-type field are the same formats.
Also, you need to adjust your field names:
a) main repeater name in theses lines
if( have_rows('date_ranges', 'option') ) {
while ( have_rows('date_ranges', 'option') ) {
b) and start/end date subfields’ names in this line
$date_ranges[] = get_sub_field('start_date') . ' - ' . get_sub_field('end_date');
I tested this code and it works fine on my end:


Best regards,
Adam