static function customer_fields_admin() { //enable dbem_bookings_tickets_single_form if enabled $EM_Form = EM_User_Fields::get_form(); $current_values = get_option('emp_gateway_customer_fields'); ?> <a name="gateway_customer_fields"></a> <div id="poststuff" class="metabox-holder"> <!-- END OF SIDEBAR --> <div id="post-body"> <div id="post-body-content"> <div id="em-booking-form-editor" class="stuffbox"> <h3> <?php _e('Common User Fields for Gateways', 'em-pro'); ?> </h3> <div class="inside"> <p><?php _e('In many cases, customer address information is required by gateways for verification. This section connects your custom fields to commonly used customer information fields.', 'em-pro'); ?> </p> <p><?php _e('After creating user fields above, you should link them up in here so some gateways can make use of them when processing payments.', 'em-pro'); ?> </p> <form action="#gateway_customer_fields" method="post"> <table class="form-table"> <tr><td><?php _e('Name (first/last)', 'em-pro'); ?> </td><td><em><?php _e('Generated accordingly from user first/last name or full name field. If a name field isn\'t provided in your booking form, the username will be used instead.', 'em-pro'); ?> </em></td></tr> <tr><td><?php _e('Email', 'em-pro'); ?> </td><td><em><?php _e('Uses the WordPress account email associated with the user.', 'em-pro'); ?> </em></td></tr> <?php foreach (self::$customer_fields as $field_key => $field_val) { ?> <tr> <td><?php echo $field_val; ?> </td> <td> <select name="<?php echo $field_key; ?> "> <option value="0"><?php echo _e('none selected', 'em-pro'); ?> </option> <?php foreach ($EM_Form->user_fields as $field_id => $field_name) { ?> <option value="<?php echo $field_id; ?> " <?php echo $field_id == $current_values[$field_key] ? 'selected="selected"' : ''; ?> ><?php echo $field_name; ?> </option> <?php } ?> </select> </td> </tr> <?php } ?> </table> <p> <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('gateway_customer_fields_' . get_current_user_id()); ?> "> <input type="hidden" name="form_action" value="form_fields"> <input type="hidden" name="form_name" value="gateway_customer_fields" /> <input type="submit" name="events_update" value="<?php _e('Save Form', 'em-pro'); ?> " class="button-primary"> </p> </form> </div> </div> </div> </div> </div> <?php }
public static function em_bookings_added($EM_Booking) { global $wpdb; $EM_Form = self::get_form($EM_Booking->event_id, $EM_Booking); if (!empty($EM_Booking->booking_meta['registration']) && is_array($EM_Booking->booking_meta['registration']) && (!get_option('dbem_bookings_registration_disable') || is_user_logged_in())) { $user_data = array(); foreach ($EM_Booking->booking_meta['registration'] as $fieldid => $field_value) { if (trim($field_value) !== '' && array_key_exists($fieldid, $EM_Form->form_fields)) { $user_data[$fieldid] = $field_value; } } foreach ($user_data as $userkey => $uservalue) { EM_User_Fields::update_user_meta($EM_Booking->person_id, $userkey, $uservalue); } } }
public static function admin_page_actions() { global $EM_Notices; $EM_Form = self::get_form(); if (!empty($_REQUEST['page']) && $_REQUEST['page'] == 'events-manager-forms-editor') { if (!empty($_REQUEST['form_name']) && $EM_Form->form_name == $_REQUEST['form_name']) { //set up booking form field map and save/retreive previous data if (empty($_REQUEST['bookings_form_action']) && $EM_Form->editor_get_post()) { //Update Values if (count($EM_Form->get_errors()) == 0) { //prefix all with dbem $form_fields = array(); foreach ($EM_Form->form_fields as $field_id => $field) { if (substr($field_id, 0, 5) != 'dbem_' && (!defined('EMP_SHARED_CUSTOM_FIELDS') || !EMP_SHARED_CUSTOM_FIELDS)) { $field_id = $field['fieldid'] = 'dbem_' . $field_id; } $form_fields[$field_id] = $field; } update_option('em_user_fields', $form_fields); $EM_Notices->add_confirm(__('Changes Saved', 'em-pro')); self::$form = false; //reset form $EM_Form = new EM_Form($form_fields); } else { $EM_Notices->add_error($EM_Form->get_errors()); } } } } //enable dbem_bookings_tickets_single_form if enabled }
function emp_add_options() { global $wpdb; add_option('em_pro_data', array()); add_option('dbem_disable_css', false); //TODO - remove this or create dependency in admin settings //Form Stuff $booking_form_data = array('name' => __('Default', 'em-pro'), 'form' => array('name' => array('label' => __emp('Name', 'dbem'), 'type' => 'name', 'fieldid' => 'user_name', 'required' => 1), 'user_email' => array('label' => __emp('Email', 'dbem'), 'type' => 'user_email', 'fieldid' => 'user_email', 'required' => 1), 'dbem_address' => array('label' => __emp('Address', 'dbem'), 'type' => 'dbem_address', 'fieldid' => 'dbem_address', 'required' => 1), 'dbem_city' => array('label' => __emp('City/Town', 'dbem'), 'type' => 'dbem_city', 'fieldid' => 'dbem_city', 'required' => 1), 'dbem_state' => array('label' => __emp('State/County', 'dbem'), 'type' => 'dbem_state', 'fieldid' => 'dbem_state', 'required' => 1), 'dbem_zip' => array('label' => __('Zip/Post Code', 'em-pro'), 'type' => 'dbem_zip', 'fieldid' => 'dbem_zip', 'required' => 1), 'dbem_country' => array('label' => __emp('Country', 'dbem'), 'type' => 'dbem_country', 'fieldid' => 'dbem_country', 'required' => 1), 'dbem_phone' => array('label' => __emp('Phone', 'dbem'), 'type' => 'dbem_phone', 'fieldid' => 'dbem_phone'), 'dbem_fax' => array('label' => __('Fax', 'em-pro'), 'type' => 'dbem_fax', 'fieldid' => 'dbem_fax'), 'booking_comment' => array('label' => __emp('Comment', 'dbem'), 'type' => 'textarea', 'fieldid' => 'booking_comment'))); add_option('em_booking_form_error_required', __('Please fill in the field: %s', 'em-pro')); $new_fields = array('dbem_address' => array('label' => __emp('Address', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_address', 'required' => 1), 'dbem_address_2' => array('label' => __emp('Address Line 2', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_address_2'), 'dbem_city' => array('label' => __emp('City/Town', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_city', 'required' => 1), 'dbem_state' => array('label' => __emp('State/County', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_state', 'required' => 1), 'dbem_zip' => array('label' => __('Zip/Post Code', 'em-pro'), 'type' => 'text', 'fieldid' => 'dbem_zip', 'required' => 1), 'dbem_country' => array('label' => __emp('Country', 'dbem'), 'type' => 'country', 'fieldid' => 'dbem_country', 'required' => 1), 'dbem_phone' => array('label' => __emp('Phone', 'dbem'), 'type' => 'text', 'fieldid' => 'dbem_phone'), 'dbem_fax' => array('label' => __('Fax', 'em-pro'), 'type' => 'text', 'fieldid' => 'dbem_fax'), 'dbem_company' => array('label' => __('Company', 'em-pro'), 'type' => 'text', 'fieldid' => 'dbem_company')); add_option('em_user_fields', $new_fields); $customer_fields = array('address' => 'dbem_address', 'address_2' => 'dbem_address_2', 'city' => 'dbem_city', 'state' => 'dbem_state', 'zip' => 'dbem_zip', 'country' => 'dbem_country', 'phone' => 'dbem_phone', 'fax' => 'dbem_fax', 'company' => 'dbem_company'); add_option('emp_gateway_customer_fields', $customer_fields); add_option('em_attendee_fields_enabled', defined('EM_ATTENDEES') && EM_ATTENDEES); //Gateway Stuff add_option('dbem_emp_booking_form_reg_input', 1); add_option('dbem_emp_booking_form_reg_show', 1); add_option('dbem_emp_booking_form_reg_show_email', 0); add_option('dbem_emp_booking_form_reg_show_name', !get_option('em_pro_version')); add_option('dbem_gateway_use_buttons', 0); add_option('dbem_gateway_label', __('Pay With', 'em-pro')); //paypal add_option('em_paypal_option_name', __('PayPal', 'em-pro')); add_option('em_paypal_form', '<img src="' . plugins_url('events-manager-pro/includes/images/paypal/paypal_info.png', 'events-manager') . '" width="228" height="61" />'); add_option('em_paypal_booking_feedback', __('Please wait whilst you are redirected to PayPal to proceed with payment.', 'em-pro')); add_option('em_paypal_booking_feedback_free', __emp('Booking successful.', 'dbem')); add_option('em_paypal_button', 'http://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif'); add_option('em_paypal_booking_feedback_thanks', __('Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you along with a separate email containing account details to access your booking information on this site. You may log into your account at www.paypal.com to view details of this transaction.', 'em-pro')); add_option('em_paypal_inc_tax', get_option('em_pro_version') == false); //offline add_option('em_offline_option_name', __('Pay Offline', 'em-pro')); add_option('em_offline_booking_feedback', __emp('Booking successful.', 'dbem')); add_option('em_offline_button', __('Pay Offline', 'em-pro')); //authorize.net add_option('em_authorize_aim_option_name', __('Credit Card', 'em-pro')); add_option('em_authorize_aim_booking_feedback', __emp('Booking successful.', 'dbem')); add_option('em_authorize_aim_booking_feedback_free', __('Booking successful. You have not been charged for this booking.', 'em-pro')); //email reminders add_option('dbem_cron_emails', 0); add_option('dbem_cron_emails_limit', get_option('emp_cron_emails_limit', 100)); add_option('dbem_emp_emails_reminder_subject', __('Reminder', 'em-pro') . ' - #_EVENTNAME'); $email_footer = '<br /><br />-------------------------------<br />Powered by Events Manager - http://wp-events-plugin.com'; $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />This is a reminder about your #_BOOKINGSPACES space/spaces reserved for #_EVENTNAME.<br />When : #_EVENTDATES @ #_EVENTTIMES<br />Where : #_LOCATIONNAME - #_LOCATIONFULLLINE<br />We look forward to seeing you there!<br />Yours faithfully,<br />#_CONTACTNAME", 'em-pro') . $email_footer; add_option('dbem_emp_emails_reminder_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable)); add_option('dbem_emp_emails_reminder_time', '12:00 AM'); add_option('dbem_emp_emails_reminder_days', 1); add_option('dbem_emp_emails_reminder_ical', 1); //custom emails add_option('dbem_custom_emails', 0); add_option('dbem_custom_emails_events', 1); add_option('dbem_custom_emails_events_admins', 1); add_option('dbem_custom_emails_gateways', 1); add_option('dbem_custom_emails_gateways_admins', 1); //multiple bookings add_option('dbem_multiple_bookings_feedback_added', __('Your booking was added to your shopping cart.', 'em-pro')); add_option('dbem_multiple_bookings_feedback_already_added', __('You have already booked a spot at this eventin your cart, please modify or delete your current booking.', 'em-pro')); add_option('dbem_multiple_bookings_feedback_no_bookings', __('You have not booked any events yet. Your cart is empty.', 'em-pro')); add_option('dbem_multiple_bookings_feedback_loading_cart', __('Loading Cart Contents...', 'em-pro')); add_option('dbem_multiple_bookings_feedback_empty_cart', __('Are you sure you want to empty your cart?', 'em-pro')); add_option('dbem_multiple_bookings_submit_button', __('Place Order', 'em_pro')); //multiple bookings - emails add_option('dbem_multiple_bookings_contact_email_subject', __('New Booking', 'em-pro')); $respondent_email_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) has made a booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer; add_option('dbem_multiple_bookings_contact_email_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable)); add_option('dbem_multiple_bookings_contact_email_cancelled_subject', __('Booking Cancelled', 'em-pro')); $respondent_email_body_localizable = __("#_BOOKINGNAME (#_BOOKINGEMAIL) has cancelled a booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer; add_option('dbem_multiple_bookings_contact_email_cancelled_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable)); add_option('dbem_multiple_bookings_email_confirmed_subject', __('Booking Confirmed', 'em-pro')); $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your booking has been confirmed. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY <br />We look forward to seeing you there!", 'em-pro') . $email_footer; add_option('dbem_multiple_bookings_email_confirmed_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable)); add_option('dbem_multiple_bookings_email_pending_subject', __('Booking Pending', 'em-pro')); $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your booking is currently pending approval by our administrators. Once approved you will receive another confirmation email. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer; add_option('dbem_multiple_bookings_email_pending_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable)); add_option('dbem_multiple_bookings_email_rejected_subject', __('Booking Rejected', 'em-pro')); $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your requested booking has been rejected. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer; add_option('dbem_multiple_bookings_email_rejected_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable)); add_option('dbem_multiple_bookings_email_cancelled_subject', __('Booking Cancelled', 'em-pro')); $respondent_email_body_localizable = __("Dear #_BOOKINGNAME, <br />Your requested booking has been cancelled. <br />Below is a summary of your booking: <br />#_BOOKINGSUMMARY", 'em-pro') . $email_footer; add_option('dbem_multiple_bookings_email_cancelled_body', str_replace("<br />", "\n\r", $respondent_email_body_localizable)); //Version updates if (get_option('em_pro_version')) { //upgrade, so do any specific version updates if (get_option('em_pro_version') < 2.16) { //add new customer information fields $user_fields = get_option('em_user_fields', array()); update_option('em_user_fields', array_merge($new_fields, $user_fields)); } if (get_option('em_pro_version') < 2.061) { //new booking form data structure global $wpdb; //backward compatability, check first field to see if indexes start with 'booking_form_...' and change this. $form_fields = get_option('em_booking_form_fields', $booking_form_data['form']); if (is_array($form_fields)) { $booking_form_fields = array(); foreach ($form_fields as $form_field_id => $form_field_data) { foreach ($form_field_data as $field_key => $value) { $field_key = str_replace('booking_form_', '', $field_key); $booking_form_fields[$form_field_id][$field_key] = $value; } } //move booking form to meta table and update wp option with booking form id too $booking_form = serialize(array('name' => __('Default', 'em-pro'), 'form' => $booking_form_fields)); if ($wpdb->insert(EM_META_TABLE, array('meta_key' => 'booking-form', 'meta_value' => $booking_form, 'object_id' => 0))) { update_option('em_booking_form_fields', $wpdb->insert_id); } } } if (get_option('em_pro_version') < 1.6) { //make buttons the default option update_option('dbem_gateway_use_buttons', 1); if (get_option('em_offline_button_text') && !get_option('em_offline_button')) { update_option('em_offline_button', get_option('em_offline_button_text')); //merge offline quick pay button option into one } if (get_option('em_paypal_button_text') && !get_option('em_paypal_button')) { update_option('em_paypal_button', get_option('em_paypal_button_text')); //merge offline quick pay button option into one } } if (get_option('em_pro_version') < 2.243) { //fix badly stored user dates and times $EM_User_Form = EM_User_Fields::get_form(); foreach ($EM_User_Form->form_fields as $field_id => $field) { if (in_array($field['type'], array('date', 'time'))) { //search the user meta table and modify all occorunces of this value if the format isn't correct $meta_results = $wpdb->get_results("SELECT umeta_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key='" . $field_id . "'", ARRAY_A); foreach ($meta_results as $meta_result) { if (is_serialized($meta_result['meta_value'])) { $meta_value = unserialize($meta_result['meta_value']); if (is_array($meta_value) && !empty($meta_value['start'])) { $new_value = $meta_value['start']; if (!empty($meta_value['end'])) { $new_value .= ',' . $meta_value['end']; } //update this user meta with the new value $wpdb->query("UPDATE {$wpdb->usermeta} SET meta_value='{$new_value}' WHERE umeta_id='{$meta_result['umeta_id']}'"); } } } } } } if (get_option('em_pro_version') < 2.36) { //disable custom emails for upgrades, prevent unecessary features add_option('dbem_custom_emails', 0); } if (get_option('dbem_muliple_bookings_form')) { //fix badly stored user dates and times update_option('dbem_multiple_bookings_form', get_option('dbem_muliple_bookings_form')); delete_option('dbem_muliple_bookings_form'); } } else { //Booking form stuff only run on install $insert_result = $wpdb->insert(EM_META_TABLE, array('meta_value' => serialize($booking_form_data), 'meta_key' => 'booking-form', 'object_id' => 0)); add_option('em_booking_form_fields', $wpdb->insert_id); } }
function output_field($field, $post = true) { ob_start(); $required = !empty($field['required']) ? ' ' . apply_filters('emp_forms_output_field_required', '<span class="em-form-required">*</span>') : ''; switch ($field['type']) { case 'html': echo $this->output_field_input($field, $post); break; case 'text': case 'textarea': case 'checkbox': case 'date': case 'checkboxes': case 'radio': case 'select': case 'country': case 'multiselect': case 'time': $tip_type = $field['type']; if ($field['type'] == 'textarea') { $tip_type = 'text'; } if (in_array($field['type'], array('select', 'multiselect'))) { $tip_type = 'select'; } if (in_array($field['type'], array('checkboxes', 'radio'))) { $tip_type = 'selection'; } ?> <p class="input-group input-<?php echo $field['type']; ?> input-field-<?php echo $field['fieldid']; ?> "> <label for='<?php echo $field['fieldid']; ?> '> <?php if (!empty($field['options_' . $tip_type . '_tip'])) { ?> <span class="form-tip" title="<?php echo esc_attr($field['options_' . $tip_type . '_tip']); ?> "> <?php echo $field['label']; ?> <?php echo $required; ?> </span> <?php } else { ?> <?php echo $field['label']; ?> <?php echo $required; ?> <?php } ?> </label> <?php echo $this->output_field_input($field, $post); ?> </p> <?php break; case 'captcha': if (!function_exists('recaptcha_get_html')) { include_once trailingslashit(plugin_dir_path(__FILE__)) . 'includes/lib/recaptchalib.php'; } if (function_exists('recaptcha_get_html') && !is_user_logged_in()) { ?> <p class="input-group input-<?php echo $field['type']; ?> input-field-<?php echo $field['fieldid']; ?> "> <label for='<?php echo $field['fieldid']; ?> '><?php echo $field['label'] . $required; ?> </label> <?php echo $this->output_field_input($field, $post); } break; default: if (array_key_exists($field['type'], $this->user_fields) && self::show_reg_fields($field)) { if (array_key_exists($field['type'], $this->core_user_fields)) { if ($field['type'] == 'user_password') { ?> <p class="input-<?php echo $field['type']; ?> input-user-field"> <label for='<?php echo $field['fieldid']; ?> '> <?php if (!empty($field['options_reg_tip'])) { ?> <span class="form-tip" title="<?php echo esc_attr($field['options_reg_tip']); ?> "> <?php echo $field['label']; ?> <?php echo $required; ?> </span> <?php } else { ?> <?php echo $field['label']; ?> <?php echo $required; ?> <?php } ?> </label> <input type="password" name="<?php echo $field['fieldid']; ?> " /> </p> <?php } else { //registration fields if (empty($_REQUEST[$field['fieldid']]) && is_user_logged_in() && get_option('dbem_emp_booking_form_reg_show') && !EM_Bookings::$force_registration) { $post = EM_User_Fields::get_user_meta(get_current_user_id(), $field['type']); } ?> <p class="input-<?php echo $field['type']; ?> input-user-field"> <label for='<?php echo $field['fieldid']; ?> '> <?php if (!empty($field['options_reg_tip'])) { ?> <span class="form-tip" title="<?php echo esc_attr($field['options_reg_tip']); ?> "> <?php echo $field['label']; ?> <?php echo $required; ?> </span> <?php } else { ?> <?php echo $field['label']; ?> <?php echo $required; ?> <?php } ?> </label> <?php echo $this->output_field_input($field, $post); ?> </p> <?php } } elseif (array_key_exists($field['type'], $this->custom_user_fields)) { ?> <p class="input-<?php echo $field['type']; ?> input-user-field"> <label for='<?php echo $field['fieldid']; ?> '> <?php if (!empty($field['options_reg_tip'])) { ?> <span class="form-tip" title="<?php echo esc_attr($field['options_reg_tip']); ?> "> <?php echo $field['label']; ?> <?php echo $required; ?> </span> <?php } else { ?> <?php echo $field['label']; ?> <?php echo $required; ?> <?php } ?> </label> <?php do_action('em_form_output_field_custom_' . $field['type'], $field, $post); ?> </p> <?php } } break; } return apply_filters('emp_forms_output_field', ob_get_clean(), $this, $field); }