Getting field values from FF Entries


This Discussion is public


My site will allow users to sign up for an Event, a car show (concours) to be specific. There will normally be many events, so the sign-up form has a dropdown list of events to be selected from. While the user can sign up for multiple events, I wish to prevent multiple sign-ups to the same event. the attached file shows my attempt at validation, so far not working. I believe the code and my problem are evident in the code, but will elaborate if needed.

Any suggestions welcome.



It looks like you used these to get started....

...but went your own way with the code that makes it work. I would go with the first option since you only need to check one field. The Left Join will be much more efficient than iterating the array as well. It takes just two simple changes and would look like this (assuming field 377 is your event ID/Name etc)...
add_filter('frm_validate_field_entry', 'my_custom_validation', 10, 3);
function my_custom_validation($errors, $posted_field, $posted_value){
if($posted_field->id == 377 and !is_admin()){ //change 125 to the ID of the field to validate
global $wpdb, $user_ID;
$entry_id = (isset($_POST['id'])) ? $_POST['id'] : 0;
$entries = $wpdb->get_col($wpdb->prepare("SELECT item_id FROM ". $wpdb->prefix ."frm_item_metas em LEFT JOIN ". $wpdb->prefix ."frm_items e ON (em.item_id = WHERE em.field_id=%d AND em.meta_value=%s AND item_id != %d AND user_id = %d", $posted_field->id, $_POST['item_meta'][$posted_field->id], $entry_id, $user_ID));
if(count($entries) >= 1) //limit to one entry per option.
$errors['field'. $posted_field->id] = 'You have already signed up for this event.';
return $errors;

I received a noreply email answer to this from Brian Johnson. I'd like to thank him, and tell him I actually stumbled upon the same example and it works for me...

However, Brian said it required 2 changes, whereas I had to make only one... changing the field ID 125 to mine, 377.

Brian, if you see this can you tell me what the 2nd change you made is? I did look at your code but can't spot it.

Ed Sowell

Hi Ed -

Glad it worked! The second change was just the changing the error text to display your custom message. Easy.

Also, not sure why you got a noreply email - I did get the email message.

Have a good one!

I wasn't even aware that it was possible to send a member-to-member email until I got the one from you.


Those are just notifications from the Forums when you receive a reply in a thread that you've posted in.

Oh, I get it. It must be because I opted for email notifications when one of my posts was replied to.

Reply to this Discussion