Skip to content

Instantly share code, notes, and snippets.

@omniacode
Last active December 2, 2022 16:56
Show Gist options
  • Save omniacode/2514d3c84a80aa76e99234ff9c87d68e to your computer and use it in GitHub Desktop.
Save omniacode/2514d3c84a80aa76e99234ff9c87d68e to your computer and use it in GitHub Desktop.
Formidable Forms - Limit Amount of Tickets that Can Be Purchased
<?php
add_filter('frm_validate_field_entry', 'max_100_tickets', 10, 3);
function max_100_tickets( $errors, $posted_field, $posted_value ) {
$field_id = 249; // change this to the ID of the Quantity Field
$tickets_requested = $_POST['item_meta'][249]; //Change 249 to the field containing the number of tickets being requested
$remaining_tickets = $_POST['item_meta'][281]; //Change 281 to the calculated field containing the number of remaining tickets
if( $tickets_requested > $remaining_tickets ) {
$errors[ 'field' . $field_id ] = "You've requested more tickets than available. Please try again";
}
return $errors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment