Home › Forums › Quform WordPress › Limiting the number of entries – two date in one form
- This topic has 5 replies, 3 voices, and was last updated 11 months ago by Ally.
- AuthorPosts
- October 5, 2020 at 6:43 pm #32029Dixx37Participant
Hello ๐
I use the form to register for events. Sometimes it happens that one event has two dates. I would like to set the limit of registrations separately for one date and for the other one (I choose “select menu” to enter the date).
Event name
Date:
(Select menu)
22.10.2020 – max 10 entries
28.10.2020 – max 10 entrieswhen i use this:
i set 10 entries for all date. Then there can be 5 records for one date and 15 records for the other date. ๐
Some time i have 8 date in one form, so i must create 8 form ๐
October 7, 2020 at 10:46 am #32042AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
October 8, 2020 at 9:04 pm #32044Dixx37ParticipantIt’s great!
Thank you very muchI have two questions:
1) Is it possible to make the date, which is full, disappear from the selection choice?
When 22.10.2020 it’s full, people don’t see this date in form.
2. is it possible to display somewhere (as an admin – in the back or in the entry) how many slots are left for each date?
- This reply was modified 4 years, 2 months ago by Dixx37.
October 9, 2020 at 9:59 am #32049AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 23, 2024 at 3:26 pm #36440janheuParticipantHi, Iยดm coming back to this post since I have a similar idea.
We have multiple Dates set in a option field. Based on a selection made before,First the user selects a place via dropdown -> afterwards he/she can select a date (option) based on that selection.
add_action('quform_pre_display_33', function (Quform_Form $form) {
global $wpdb;
$query = "SELECT COUNT(*)
FROM {$wpdb->prefix}quform_entry_data ed
LEFT JOIN {$wpdb->prefix}quform_entries e
ON ed.entry_id = e.id
WHERE e.form_id = %d AND ed.element_id = %d AND ed.value = %s";// Erstes Radio-Button-Element
$uniqueId1 = '33_32';
$limits1 = array(
'03.02.2024' => 6,
'24.02.2024' => 6,
);
updateRadioOptions($form, $uniqueId1, $limits1, $wpdb, $query);// Zweites Radio-Button-Element
$uniqueId2 = '33_33';
$limits2 = array(
'09.02.2024' => 6,
'17.02.2024' => 6,
);
updateRadioOptions($form, $uniqueId2, $limits2, $wpdb, $query);
});function updateRadioOptions($form, $uniqueId, $limits, $wpdb, $query) {
$radio = $form->getElement('quform_' . $uniqueId);
if ($radio instanceof Quform_Element_Radio) {
$options = array();
foreach ($radio->getOptions() as $option) {
$value = isset($option['value']) ? $option['value'] : null;
if ($value && array_key_exists($value, $limits)) {
$count = $wpdb->get_var($wpdb->prepare($query, $form->getId(), $radio->getId(), $value));
if ($count < $limits[$value]) {
$options[] = $option;
}
} else {
$options[] = $option;
}
}
$radio->setOptions($options);
}
}Thats the idea, somehow it doesnt seem to work, any idea how we can adjust it?
Is there a way to display a message if all spots for this place are already booked?
thanks a lotJanuary 24, 2024 at 10:43 am #36441AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.