Exemple #1
1
 function create_object($args)
 {
     $args = wp_parse_args($args, $this->default_generation_definitions);
     return GFAPI::add_entry($args);
 }
 public function create_submission($data = null)
 {
     $settings = get_option('fwe_settings');
     $form_id = $settings['hire_us_form_id'];
     $upload_dir = WP_CONTENT_DIR . '/rfp-uploads';
     $success_msg = array_key_exists('hire_us_success_message', $settings) ? $settings['hire_us_success_message'] : 'Thank you!';
     $mime_type = $data[19];
     if ($mime_type && !in_array($mime_type, $this->allowed_mime_types)) {
         return new WP_Error('That file type is not allowed.');
     }
     $invalid_fields = $this->validate_submission($data);
     if (!empty($invalid_fields)) {
         return new WP_Error('The following required fields were invalid: ' . implode(', ', $invalid_fields));
     }
     // Make the uploads folder if it doesn't exist
     if (!is_dir($upload_dir)) {
         $mkdir_success = wp_mkdir_p($upload_dir);
         if (!$mkdir_success) {
             return new WP_Error('Could not create upload directory.');
         }
     }
     // Save the RFP file data as a file on the server
     if (!empty($data['rfp_file_data'])) {
         $filename = wp_unique_filename($upload_dir, $data[20]);
         $file_data = $this->get_binary_data($data['rfp_file_data']);
         $upload_path = trailingslashit($upload_dir) . $filename;
         $file_url = content_url('/rfp-uploads/' . $filename);
         if (!file_put_contents($upload_path, $file_data)) {
             return new WP_Error('Error saving RFP file.');
         }
         // Don't store base64 garbage in the database
         unset($data['rfp_file_data']);
     }
     // Store the form responses in Gravity Forms
     $data['form_id'] = $form_id;
     $data['date_created'] = strftime('%Y-%m-%d %H:%M');
     $data[21] = $file_url;
     $entry_id = GFAPI::add_entry($data);
     // Give the user back a sanitized version of their input for displaying on the Thank You message
     $response_data = array_merge($data, array('status' => 'OK', 'entry_id' => $entry_id, 'message' => $success_msg));
     unset($response_data[21]);
     $response = new WP_JSON_Response();
     $response->set_data($response_data);
     return $response;
 }
                $entry['123'] = $trustees3->trusteesContactLastName;
                $entry['30'] = $trustees4->trusteesContactFirstName;
                $entry['124'] = $trustees4->trusteesContactLastName;
                $entry['103'] = $trustees1->trusteesAddress;
            }
            //print_r($entry);
            //$importResult = $formId.GFAPI::add_entry($entry);
            //exit;
            break;
            //case XXXXXXXXX: //Investment Strategy
            //	$entry['1'] = $fundName;
            //break;
    }
    // End switch case
    // Add entry to database
    $importResult = $formId . GFAPI::add_entry($entry);
}
// End post
?>

	<!--TEMPLATE DISPLAY-->
	<!-- BEGIN CONTAINER -->
	<div class="page-container">
		<?php 
get_sidebar();
?>
		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content">
				<h1><?php 
the_title();
    //
    //    echo"<br>";
    //    echo "<pre>";
    //        print_r($_POST['entry']);
    //    echo "</pre>";
    if (isset($_POST['entry']) && !empty($_POST['entry'])) {
        $post_entry = (array) $_POST['entry'];
        $form_id = $post_entry['form_id'];
        $entry = setup_entry($post_entry);
        $entry['orderStatus'] = 'incomplete';
        //        echo "<pre>";
        //            echo "below is the result of your effort <br>";
        //            print_r($entry);
        //        echo "</pre>";
        //        exit;
        $entry_ids = GFAPI::add_entry($entry, $form_id);
        if (is_array($entry_ids) === false) {
            echo json_encode(array('success' => $entry_ids));
            $to = '*****@*****.**';
            $subject = 'Content Empty';
            $message = 'Data: <br/>' . print_r($entry, true);
            //wp_mail( $to, $subject, $message);
        } else {
            echo json_encode(array('error' => "Ooops, something went wrong try again later." . $entry_ids));
            /*echo json_encode(array('error'=>$entry_ids));*/
        }
    }
} else {
    echo json_encode(array('error' => "You must be logged in."));
}
/**   
 /**
  * Add the user's form entry data
  */
 private function add_entry($entry)
 {
     $this->delete_entry($entry['form_id']);
     $entry_id = GFAPI::add_entry($entry);
     $_SESSION['gform_sayg_entry_id_' . $entry['form_id']] = $entry_id;
 }
Exemple #6
0
 /**
  * Generate some placeholder values to test against
  */
 private function create_stubs()
 {
     add_role('zero', "No Capabilities", array());
     $this->form_id = GFAPI::add_form(array('title' => 'This is the form title', 'fields' => array(new GF_Field_Text(array('id' => 1, 'label' => 'Label for field one (text)', 'choices' => array(), 'inputs' => '')), new GF_Field_Hidden(array('id' => 2, 'label' => 'Label for field two (hidden)', 'choices' => array(), 'inputs' => '')), new GF_Field_Number(array('id' => 3, 'label' => 'Label for field three (number)', 'choices' => array(), 'inputs' => '')))));
     $this->form = GFAPI::get_form($this->form_id);
     $entry_array = array('form_id' => $this->form_id, '1' => 'Value for field one', '2' => 'Value for field two', '3' => '3.33333', 'ip' => '127.0.0.1', 'source_url' => 'http://example.com/wordpress/?gf_page=preview&id=16', 'user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2', 'payment_status' => 'Processing', 'payment_date' => '2014-08-29 20:55:06', 'payment_amount' => '0.01', 'transaction_id' => 'asdfpaoj442gpoagfadf', 'created_by' => 1, 'status' => 'active', 'date_created' => '2014-08-29 18:25:39');
     $this->entry_id = GFAPI::add_entry($entry_array);
     $this->entry = GFAPI::get_entry($this->entry_id);
 }
 function create_object($entry)
 {
     return GFAPI::add_entry($entry);
 }
 private function addGFEntry($leadUserInfo, $gFormId)
 {
     // add entry
     $entry = array("form_id" => $gFormId);
     foreach ($leadUserInfo['field_data'] as $leadField) {
         if (null != ($mappedFieldId = $this->getMappedFieldId($leadField['name'], $gFormId))) {
             $entry[$mappedFieldId] = $leadField['values'][0];
         }
     }
     // Adding hidden fields with default values presented
     $gfForm = GFAPI::get_form($gFormId);
     if (!empty($gfForm['fields'])) {
         foreach ($gfForm['fields'] as $field) {
             if ($field->type == 'hidden' && $field->defaultValue != '') {
                 $entry[$field->id] = $field->defaultValue;
             }
         }
     }
     $entryId = GFAPI::add_entry($entry);
     // Force trigger MailChimp plugin
     if (class_exists('GFMailChimp')) {
         $mailchimp = GFMailChimp::get_instance();
         $gfForm = GFAPI::get_form($gFormId);
         $mailchimp->maybe_process_feed($entry, $gfForm);
     }
     // Force trigger Zapier plugin
     if (class_exists('GFZapier')) {
         $gfForm = GFAPI::get_form($gFormId);
         GFZapier::send_form_data_to_zapier($entry, $gfForm);
     }
     // send notifications
     $this->sendNotifications($gFormId, $entryId);
 }
Exemple #9
0
function makeAdminCopyEntry()
{
    $entryID = isset($_POST['copy_entry_id']) ? $_POST['copy_entry_id'] : 0;
    $copy2Form = isset($_POST['copy2Form']) ? $_POST['copy2Form'] : '';
    $view_id = isset($_POST['view_id']) ? $_POST['view_id'] : 0;
    if ($entryID != 0 and $copy2Form != '' && $view_id != 0) {
        //get entry data
        $lead = GFAPI::get_entry(esc_attr($entryID));
        //get new form field ID's
        $form = GFAPI::get_form($copy2Form);
        /*The following fields will not be copied from one entry to another
         * Page 4 review fields:
         * 295 - Are you 18 years or older
         * 114 - Full Name
         * 297 - I am the parent and/or legal guardian of 
         * 115 - Date
         * 117 - Release and consent
         * all admin only fields
         */
        $doNotCopy = array(295, 114, 297, 115, 117);
        /*loop thru fields in existing entry and if they are in the new form copy them */
        $newEntry = array();
        $newEntry['form_id'] = $copy2Form;
        foreach ($form['fields'] as $field) {
            //skip doNotCopy fields
            if (!in_array($field['id'], $doNotCopy)) {
                //do not copy admin only fields
                $adminOnly = isset($field['adminOnly']) ? $field['adminOnly'] : FALSE;
                if (!$adminOnly) {
                    if (is_array($field['inputs'])) {
                        foreach ($field['inputs'] as $inputs) {
                            $fieldID = $inputs['id'];
                            if (isset($lead[$fieldID])) {
                                $newEntry[$fieldID] = $lead[$fieldID];
                            }
                        }
                    }
                    if (isset($lead[$field['id']])) {
                        $newEntry[$field['id']] = $lead[$field['id']];
                    }
                }
            }
        }
        $newEntry['303'] = 'In Progress';
        //in-progress
        $newEntry_id = GFAPI::add_entry($newEntry);
        $entry = GFAPI::get_entry($newEntry_id);
        $href = GravityView_Edit_Entry::get_edit_link($entry, $view_id);
        echo 'New Entry created:' . $newEntry_id . '. Please click <a href="entry/' . $newEntry_id . '/' . $href . '">here</a> to finish the submission process';
    } else {
        echo 'Error in creating a new entry. Proper data was not received.';
    }
    exit;
}
 public static function create_assessment_entry($entry)
 {
     return \GFAPI::add_entry($entry);
 }