Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    Not without adding some PHP to hook into the event saving process (specifically em_event_validate fired in classes/em-event.php)

    Alternatively, Pro has a custom booking form feature that allows required fields to be added.

    Thread Starter geologist

    (@geologist)

    Thanks Marcus. Knowing which file to modify is a big help. Not quite ready to buy the Pro version yet; not till we’re ready to start accepting online payments.

    you can try this snippet (paste in your theme functions.php)

    function em_validate(){
     global $EM_Event,$EM_Notices;
     if ($_REQUEST['field_name'] == ''){
      $EM_Notices->add_error('guest name is required...');
     }
    }
    add_filter('em_event_validate','em_validate');

    Thread Starter geologist

    (@geologist)

    This is not quite working. After adding the validation function to my theme functions file, the user always get the message “guest name is required…”. This happens when any required information is left off the form (either name or email). It also happens when all correction info is put in the form, and no registration (booking) occurs.

    I should clarify. Are you suggesting that I add the validation function to the functions file in addition to modifying the em-event.php file?

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    you need to change ‘field_name’ to that of your html input field e.g. user_name

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    mind you you may want to change that to e.g.

    function em_validate(){
     global $EM_Event,$EM_Notices;
     if (!is_user_logged_in() && $_REQUEST['user_name'] == ''){
      $EM_Notices->add_error('guest name is required...');
     }
    }
    add_filter('em_event_validate','em_validate');
    Thread Starter geologist

    (@geologist)

    Still no booking taking place, even when all required fields are completed. When email is left blank an empty red box displays for a message, but there is no text in the box. The “guest name is required” message is is working correctly.

    I have this set up so that guest does not have to be logged in or be a registered WordPress User to book an event. So I’m thinking that (!is_user_logged_in() should not be in the function, but deleting it completely breaks my site.

    Thread Starter geologist

    (@geologist)

    Correction – I deleted too much from !is_user_logged_in(). But even when I modify that correctly, it doesn’t help. Same issues as listed above.

    I have this set up so that guest does not have to be logged in or be a registered WordPress User to book an event

    have you tried No-User Booking Mode -> https://wp-events-plugin.com/documentation/booking-options/

    Settings > Bookings > No-User Booking Mode

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    oops, missed something else out in the above, since it’s a filter:

    function em_validate($result, $EM_Event){
     if (!is_user_logged_in() && $_REQUEST['user_name'] == ''){
      $EM_Event->add_error('guest name is required...');
      $result = false;
     }
     return $result;
    }
    add_filter('em_event_validate','em_validate', 1, 2);
    Thread Starter geologist

    (@geologist)

    Yes, Agelonwl. I have seen the booking-options and the No-User Booking Mode. Am I missing something? I don’t see anywhere that I can specify which fields on the booking form are required.

    Thread Starter geologist

    (@geologist)

    Alright Marcus, that worked!!

    Thanks so much.

    This is a great plugin!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Booking Form Required Fields’ is closed to new replies.