本文整理汇总了PHP中gform_update_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP gform_update_meta函数的具体用法?PHP gform_update_meta怎么用?PHP gform_update_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gform_update_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nb_gform_post_submission
function nb_gform_post_submission($entry)
{
// add response value to entry meta
foreach ($this->nb_infogeniuz_fields as $field_group) {
foreach ($field_group as $field_key => $field_name) {
gform_update_meta($entry['id'], $field_key, esc_attr($_POST[$field_key]));
}
}
}
示例2: add_entry
/**
* Adds a single Entry object.
*
* Intended to be used for importing an entry object. The usual hooks that are triggered while saving entries are not fired here.
* Checks that the form id, field ids and entry meta exist and ignores legacy values (i.e. values for fields that no longer exist).
*
* @since 1.8
* @access public
* @static
*
* @param array $entry The Entry object
*
* @return mixed Either the new Entry ID or a WP_Error instance
*/
public static function add_entry($entry)
{
global $wpdb;
if (!is_array($entry)) {
return new WP_Error('invalid_entry_object', __('The entry object must be an array', 'gravityforms'));
}
// make sure the form id exists
$form_id = rgar($entry, 'form_id');
if (empty($form_id)) {
return new WP_Error('empty_form_id', __('The form id must be specified', 'gravityforms'));
}
if (false === self::form_id_exists($form_id)) {
return new WP_Error('invalid_form_id', __('The form for this entry does not exist', 'gravityforms'));
}
// use values in the entry object if present
$post_id = isset($entry['post_id']) ? intval($entry['post_id']) : 'NULL';
$date_created = isset($entry['date_created']) && $entry['date_created'] != '' ? sprintf("'%s'", esc_sql($entry['date_created'])) : 'utc_timestamp()';
$is_starred = isset($entry['is_starred']) ? $entry['is_starred'] : 0;
$is_read = isset($entry['is_read']) ? $entry['is_read'] : 0;
$ip = isset($entry['ip']) ? $entry['ip'] : GFFormsModel::get_ip();
$source_url = isset($entry['source_url']) ? $entry['source_url'] : esc_url_raw(GFFormsModel::get_current_page_url());
$user_agent = isset($entry['user_agent']) ? $entry['user_agent'] : 'API';
$currency = isset($entry['currency']) ? $entry['currency'] : GFCommon::get_currency();
$payment_status = isset($entry['payment_status']) ? sprintf("'%s'", esc_sql($entry['payment_status'])) : 'NULL';
$payment_date = strtotime(rgar($entry, 'payment_date')) ? sprintf("'%s'", gmdate('Y-m-d H:i:s', strtotime("{$entry['payment_date']}"))) : 'NULL';
$payment_amount = isset($entry['payment_amount']) ? (double) $entry['payment_amount'] : 'NULL';
$payment_method = isset($entry['payment_method']) ? $entry['payment_method'] : '';
$transaction_id = isset($entry['transaction_id']) ? sprintf("'%s'", esc_sql($entry['transaction_id'])) : 'NULL';
$is_fulfilled = isset($entry['is_fulfilled']) ? intval($entry['is_fulfilled']) : 'NULL';
$status = isset($entry['status']) ? $entry['status'] : 'active';
global $current_user;
$user_id = isset($entry['created_by']) ? absint($entry['created_by']) : '';
if (empty($user_id)) {
$user_id = $current_user && $current_user->ID ? absint($current_user->ID) : 'NULL';
}
$transaction_type = isset($entry['transaction_type']) ? intval($entry['transaction_type']) : 'NULL';
$lead_table = GFFormsModel::get_lead_table_name();
$result = $wpdb->query($wpdb->prepare("\n INSERT INTO {$lead_table}\n (form_id, post_id, date_created, is_starred, is_read, ip, source_url, user_agent, currency, payment_status, payment_date, payment_amount, transaction_id, is_fulfilled, created_by, transaction_type, status, payment_method)\n VALUES\n (%d, {$post_id}, {$date_created}, %d, %d, %s, %s, %s, %s, {$payment_status}, {$payment_date}, {$payment_amount}, {$transaction_id}, {$is_fulfilled}, {$user_id}, {$transaction_type}, %s, %s)\n ", $form_id, $is_starred, $is_read, $ip, $source_url, $user_agent, $currency, $status, $payment_method));
if (false === $result) {
return new WP_Error('insert_entry_properties_failed', __('There was a problem while inserting the entry properties', 'gravityforms'), $wpdb->last_error);
}
// reading newly created lead id
$entry_id = $wpdb->insert_id;
$entry['id'] = $entry_id;
// only save field values for fields that currently exist in the form
$form = GFFormsModel::get_form_meta($form_id);
foreach ($form['fields'] as $field) {
/* @var GF_Field $field */
if (in_array($field->type, array('html', 'page', 'section'))) {
continue;
}
$inputs = $field->get_entry_inputs();
if (is_array($inputs)) {
foreach ($inputs as $input) {
$input_id = (string) $input['id'];
if (isset($entry[$input_id])) {
$result = GFFormsModel::update_lead_field_value($form, $entry, $field, 0, $input_id, $entry[$input_id]);
if (false === $result) {
return new WP_Error('insert_input_value_failed', __('There was a problem while inserting one of the input values for the entry', 'gravityforms'), $wpdb->last_error);
}
}
}
} else {
$field_id = $field->id;
$field_value = isset($entry[(string) $field_id]) ? $entry[(string) $field_id] : '';
$result = GFFormsModel::update_lead_field_value($form, $entry, $field, 0, $field_id, $field_value);
if (false === $result) {
return new WP_Error('insert_field_values_failed', __('There was a problem while inserting the field values', 'gravityforms'), $wpdb->last_error);
}
}
}
// add save the entry meta values - only for the entry meta currently available for the form, ignore the rest
$entry_meta = GFFormsModel::get_entry_meta($form_id);
if (is_array($entry_meta)) {
foreach (array_keys($entry_meta) as $key) {
if (isset($entry[$key])) {
gform_update_meta($entry_id, $key, $entry[$key], $form['id']);
}
}
}
// Refresh the entry
$entry = GFAPI::get_entry($entry['id']);
/**
* Fires after the Entry is added using the API.
*
* @since 1.9.14.26
//.........这里部分代码省略.........
示例3: pluploader_trash_checkbox
/**
* pluploader_trash_checkbox
*
* Called by 'gform_update_status' gravity forms action.
* Handles the meta data for an entry relating to the deletion
* of any plupload files attached the entry.
*
* @access public
* @author Ben Moody
*/
public function pluploader_trash_checkbox($lead_id, $property_value, $previous_value)
{
if (isset($property_value) && $property_value === 'trash') {
if (isset($_POST['prso_pluploader_delete_uploads']) && $_POST['prso_pluploader_delete_uploads'] === 'on') {
//Update delete file meta for this entry
gform_update_meta($lead_id, self::$delete_files_meta_key, 'checked');
} else {
//Update delete file meta for this entry
gform_delete_meta($lead_id, self::$delete_files_meta_key);
}
}
}
示例4: get_subscription_query_string
public function get_subscription_query_string($feed, $submission_data, $entry_id)
{
if (empty($submission_data)) {
return false;
}
$query_string = '';
$payment_amount = rgar($submission_data, 'payment_amount');
$setup_fee = rgar($submission_data, 'setup_fee');
$trial_enabled = rgar($feed['meta'], 'trial_enabled');
$line_items = rgar($submission_data, 'line_items');
$discounts = rgar($submission_data, 'discounts');
$recurring_field = rgar($submission_data, 'payment_amount');
//will be field id or the text 'form_total'
$product_index = 1;
$shipping = '';
$discount_amt = 0;
$cmd = '_xclick-subscriptions';
$extra_qs = '';
$name_without_options = '';
$item_name = '';
//work on products
if (is_array($line_items)) {
foreach ($line_items as $item) {
$product_id = $item['id'];
$product_name = $item['name'];
$quantity = $item['quantity'];
$quantity_label = $quantity > 1 ? $quantity . ' ' : '';
$unit_price = $item['unit_price'];
$options = rgar($item, 'options');
$product_id = $item['id'];
$is_shipping = rgar($item, 'is_shipping');
$product_options = '';
if (!$is_shipping) {
//add options
if (!empty($options) && is_array($options)) {
$product_options = ' (';
foreach ($options as $option) {
$product_options .= $option['option_name'] . ', ';
}
$product_options = substr($product_options, 0, strlen($product_options) - 2) . ')';
}
$item_name .= $quantity_label . $product_name . $product_options . ', ';
$name_without_options .= $product_name . ', ';
}
}
//look for discounts to pass in the item_name
if (is_array($discounts)) {
foreach ($discounts as $discount) {
$product_name = $discount['name'];
$quantity = $discount['quantity'];
$quantity_label = $quantity > 1 ? $quantity . ' ' : '';
$item_name .= $quantity_label . $product_name . ' (), ';
$name_without_options .= $product_name . ', ';
}
}
if (!empty($item_name)) {
$item_name = substr($item_name, 0, strlen($item_name) - 2);
}
//if name is larger than max, remove options from it.
if (strlen($item_name) > 127) {
$item_name = substr($name_without_options, 0, strlen($name_without_options) - 2);
//truncating name to maximum allowed size
if (strlen($item_name) > 127) {
$item_name = substr($item_name, 0, 124) . '...';
}
}
$item_name = urlencode($item_name);
}
$trial = '';
//see if a trial exists
if ($trial_enabled) {
$trial_amount = rgar($submission_data, 'trial') ? rgar($submission_data, 'trial') : 0;
$trial_period_number = rgar($feed['meta'], 'trialPeriod_length');
$trial_period_type = $this->convert_interval(rgar($feed['meta'], 'trialPeriod_unit'), 'char');
$trial = "&a1={$trial_amount}&p1={$trial_period_number}&t1={$trial_period_type}";
}
//check for recurring times
$recurring_times = rgar($feed['meta'], 'recurringTimes') ? '&srt=' . rgar($feed['meta'], 'recurringTimes') : '';
$recurring_retry = rgar($feed['meta'], 'recurringRetry') ? '1' : '0';
$billing_cycle_number = rgar($feed['meta'], 'billingCycle_length');
$billing_cycle_type = $this->convert_interval(rgar($feed['meta'], 'billingCycle_unit'), 'char');
$query_string = "&cmd={$cmd}&item_name={$item_name}{$trial}&a3={$payment_amount}&p3={$billing_cycle_number}&t3={$billing_cycle_type}&src=1&sra={$recurring_retry}{$recurring_times}";
//save payment amount to lead meta
gform_update_meta($entry_id, 'payment_amount', $payment_amount);
return $payment_amount > 0 ? $query_string : false;
}
示例5: form_save_confirmation
public function form_save_confirmation($confirmation, $form, $lead, $ajax)
{
if (!isset($form['enableFormState']) || !$form['enableFormState']) {
return $confirmation;
}
$user = wp_get_current_user();
if (!isset($_POST['gform_save_state_' . $form['id']])) {
if (!empty($form['enableFormStateOnSubmit']) && $form['enableFormStateOnSubmit']) {
/* still save, but do submit, thanks */
update_user_meta($user->ID, 'completed_form_' . $form['id'], $lead['id']);
update_user_meta($user->ID, 'has_pending_form_' . $form['id'], $lead['id']);
return $confirmation;
}
/* remove all saved data for this form and user */
delete_user_meta($user->ID, 'has_pending_form_' . $form['id']);
update_user_meta($user->ID, 'completed_form_' . $form['id'], $lead['id']);
return $confirmation;
}
if (!isset($_POST['gform_save_state_' . $form['id']])) {
return $confirmation;
}
/* this should never happend */
/* set pending to user id */
gform_update_meta($lead['id'], 'is_pending', $user->ID);
/* set latest pending */
update_user_meta($user->ID, 'has_pending_form_' . $form['id'], $lead['id']);
/* set lead to pending */
RGFormsModel::update_lead_property($lead['id'], 'status', 'pending', false, true);
GFAPI::update_entry_property($lead['id'], 'status', 'pending', false, true);
GFAPI::update_entry_property($lead['id'], 'orderStatus', 'incomplete', false, true);
$headers[] = "Content-type: text/html";
wp_mail('tim@automationlab.com.au', 'Lead Data that will be saved', print_r($lead, true), $headers);
do_action('gform_save_state', $form, $lead);
$confirmation = __('Your progress has been saved. You Lead Number for this progress is ' . $lead['id']);
return $confirmation;
}
示例6: process_feed
/**
* Process the feed!
* @param array $feed feed data and settings
* @param array $entry gf entry object
* @param array $form gf form data
*/
public function process_feed($feed, $entry, $form)
{
$paypal_feeds = $this->get_feeds_by_slug('gravityformspaypal', $form['id']);
$has_paypal_feed = false;
foreach ($paypal_feeds as $paypal_feed) {
if ($paypal_feed['is_active'] && $this->is_feed_condition_met($paypal_feed, $form, $entry)) {
$has_paypal_feed = true;
break;
}
}
$ga_event_data = $this->get_event_data($feed, $entry, $form);
if ($has_paypal_feed) {
gform_update_meta($entry['id'], 'ga_event_data', maybe_serialize($ga_event_data));
} else {
$this->track_form_after_submission($entry, $form, $ga_event_data);
}
}
开发者ID:resoundcreative-dev,项目名称:wordpress-gravity-forms-event-tracking,代码行数:23,代码来源:class-gravity-forms-event-tracking-feed.php
示例7: get_product_fields
public static function get_product_fields($form, $lead, $use_choice_text = false, $use_admin_label = false)
{
$products = array();
$product_info = null;
// retrieve static copy of product info (only for "real" entries)
if (!rgempty("id", $lead)) {
$product_info = gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
}
// if no static copy, generate from form/lead info
if (!$product_info) {
foreach ($form["fields"] as $field) {
$id = $field["id"];
$lead_value = RGFormsModel::get_lead_field_value($lead, $field);
$quantity_field = self::get_product_fields_by_type($form, array("quantity"), $id);
$quantity = sizeof($quantity_field) > 0 && !RGFormsModel::is_field_hidden($form, $quantity_field[0], array(), $lead) ? RGFormsModel::get_lead_field_value($lead, $quantity_field[0]) : 1;
switch ($field["type"]) {
case "product":
//ignore products that have been hidden by conditional logic
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array(), $lead);
if ($is_hidden) {
continue;
}
//if single product, get values from the multiple inputs
if (is_array($lead_value)) {
$product_quantity = sizeof($quantity_field) == 0 && !rgar($field, "disableQuantity") ? rgget($id . ".3", $lead_value) : $quantity;
if (empty($product_quantity)) {
continue;
}
if (!rgget($id, $products)) {
$products[$id] = array();
}
$products[$id]["name"] = $use_admin_label && !rgempty("adminLabel", $field) ? $field["adminLabel"] : $lead_value[$id . ".1"];
$products[$id]["price"] = $lead_value[$id . ".2"];
$products[$id]["quantity"] = $product_quantity;
} else {
if (!empty($lead_value)) {
if (empty($quantity)) {
continue;
}
if (!rgar($products, $id)) {
$products[$id] = array();
}
if ($field["inputType"] == "price") {
$name = $field["label"];
$price = $lead_value;
} else {
list($name, $price) = explode("|", $lead_value);
}
$products[$id]["name"] = !$use_choice_text ? $name : RGFormsModel::get_choice_text($field, $name);
$products[$id]["price"] = $price;
$products[$id]["quantity"] = $quantity;
$products[$id]["options"] = array();
}
}
if (isset($products[$id])) {
$options = self::get_product_fields_by_type($form, array("option"), $id);
foreach ($options as $option) {
$option_value = RGFormsModel::get_lead_field_value($lead, $option);
$option_label = empty($option["adminLabel"]) ? $option["label"] : $option["adminLabel"];
if (is_array($option_value)) {
foreach ($option_value as $value) {
$option_info = self::get_option_info($value, $option, $use_choice_text);
if (!empty($option_info)) {
$products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
}
}
} else {
if (!empty($option_value)) {
$option_info = self::get_option_info($option_value, $option, $use_choice_text);
$products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
}
}
}
}
break;
}
}
$shipping_field = self::get_fields_by_type($form, array("shipping"));
$shipping_price = $shipping_name = "";
if (!empty($shipping_field) && !RGFormsModel::is_field_hidden($form, $shipping_field[0], array(), $lead)) {
$shipping_price = RGFormsModel::get_lead_field_value($lead, $shipping_field[0]);
$shipping_name = $shipping_field[0]["label"];
if ($shipping_field[0]["inputType"] != "singleshipping") {
list($shipping_method, $shipping_price) = explode("|", $shipping_price);
$shipping_name = $shipping_field[0]["label"] . " ({$shipping_method})";
}
}
$shipping_price = self::to_number($shipping_price);
$product_info = array("products" => $products, "shipping" => array("name" => $shipping_name, "price" => $shipping_price));
$product_info = apply_filters("gform_product_info_{$form["id"]}", apply_filters("gform_product_info", $product_info, $form, $lead), $form, $lead);
// save static copy of product info (only for "real" entries)
if (!rgempty("id", $lead) && !empty($product_info["products"])) {
gform_update_meta($lead['id'], "gform_product_info_{$use_choice_text}_{$use_admin_label}", $product_info);
}
}
return $product_info;
}
示例8: entry_post_save
public function entry_post_save($entry, $form)
{
//Abort if authorization wasn't done.
if (empty($this->authorization)) {
return $entry;
}
$feed = $this->authorization["feed"];
if ($feed["meta"]["transactionType"] == "product") {
if ($this->payment_method_is_overridden('capture') && rgempty("captured_payment", $this->authorization)) {
$capture_response = $this->capture($this->authorization, $feed, $this->authorization["submission_data"], $form, $entry);
$this->authorization["captured_payment"] = $capture_response;
}
$this->process_capture($this->authorization, $feed, $this->authorization["submission_data"], $form, $entry);
} else {
if ($feed["meta"]["transactionType"] == "subscription") {
$this->process_subscription($this->authorization, $feed, $this->authorization["submission_data"], $form, $entry);
}
}
gform_update_meta($entry["id"], "payment_gateway", $this->_slug);
return $entry;
}
示例9: paypal_fulfillment
public function paypal_fulfillment($entry, $config, $transaction_id, $amount)
{
self::log_debug("Checking PayPal fulfillment for transaction {$transaction_id}");
$is_fulfilled = gform_get_meta($entry['id'], "{$this->_slug}_is_fulfilled");
if (!$is_fulfilled) {
self::log_debug("Entry {$entry['id']} has not been fulfilled.");
$form = RGFormsModel::get_form_meta($entry['form_id']);
$this->maybe_process_feed($entry, $form, true);
// updating meta to indicate this entry has been fulfilled for the current add-on
self::log_debug("Marking entry {$entry['id']} as fulfilled");
gform_update_meta($entry['id'], "{$this->_slug}_is_fulfilled", true);
} else {
self::log_debug("Entry {$entry['id']} is already fulfilled.");
}
}
示例10: form_save_confirmation
public function form_save_confirmation($confirmation, $form, $lead, $ajax)
{
if (!isset($form['enableFormState']) || !$form['enableFormState']) {
return $confirmation;
}
$user = wp_get_current_user();
if (!isset($_POST['gform_save_state_' . $form['id']])) {
if (!empty($form['enableFormStateOnSubmit']) && $form['enableFormStateOnSubmit']) {
/* still save, but do submit, thanks */
update_user_meta($user->ID, 'completed_form_' . $form['id'], $lead['id']);
update_user_meta($user->ID, 'has_pending_form_' . $form['id'], $lead['id']);
return $confirmation;
}
/* remove all saved data for this form and user */
delete_user_meta($user->ID, 'has_pending_form_' . $form['id']);
update_user_meta($user->ID, 'completed_form_' . $form['id'], $lead['id']);
return $confirmation;
}
if (!isset($_POST['gform_save_state_' . $form['id']])) {
return $confirmation;
}
/* this should never happend */
/* set pending to user id */
gform_update_meta($lead['id'], 'is_pending', $user->ID);
/* set latest pending */
update_user_meta($user->ID, 'has_pending_form_' . $form['id'], $lead['id']);
/* set lead to pending */
RGFormsModel::update_lead_property($lead['id'], 'status', 'pending', false, true);
do_action('gform_save_state', $form, $lead);
$confirmation = __('Your progress has been saved. You can return to this form anytime in the future to complete it.');
return $confirmation;
}
示例11: render_pdfs
function render_pdfs($entry, $form)
{
$form_id = $_GET["fid"] = $entry["form_id"];
$lead_id = $_GET["lid"] = $entry["id"];
$dompdf = process_print_view();
$pdf = $dompdf->output();
$folder = WP_CONTENT_DIR . "/rendered_forms/{$form_id}/{$lead_id}/";
$filename = "form-{$form_id}-entry-{$lead_id}.pdf";
$url = content_url() . "/rendered_forms/{$form_id}/{$lead_id}/" . $filename;
$full_path = $folder . $filename;
print mkdir($folder, 0777, true);
$fp = fopen($full_path, "a+");
fwrite($fp, $pdf);
fclose($fp);
gform_update_meta($lead_id, "gf_pdf_filename", $full_path);
gform_update_meta($lead_id, "gf_pdf_url", $url);
}
示例12: create
private static function create($entry, $form, $feed)
{
self::log_debug(__METHOD__ . ': Starting the create process...');
$api = self::get_api();
$token = self::getToken();
// There was no token. This is all wrong.
if (empty($token)) {
self::log_error(__METHOD__ . ': There was no OAuth token. It was likely revoked. Aborting.');
return false;
}
if (!isset($feed['is_active']) || $feed['is_active'] == 0) {
self::log_error(sprintf('%s: Feed `%s` is not active.', __METHOD__, $feed['meta']['contact_object_name']));
return false;
}
$merge_vars = self::process_merge_vars($entry, $form, $feed);
$merge_vars = apply_filters('gf_salesforce_create_data', $merge_vars, $form, $entry, $feed, $api);
// Make sure the charset is UTF-8 for Salesforce.
$merge_vars = array_map(array('GFSalesforce', '_convert_to_utf_8'), $merge_vars);
// Don't send merge_vars that are empty. It can cause problems with Salesforce strict typing. For example,
// if the form has a text field where a number should go, but that number isn't always required, when it's
// not supplied, we don't want to send <var></var> to Salesforce. It might choke because it expects a Double
// data type, not an empty string
$merge_vars = array_filter($merge_vars, array('GFSalesforce', '_remove_empty_fields'));
// We create the object to insert/upsert into Salesforce
$Account = new SObject();
// The fields to use are the merge vars
$Account->fields = $merge_vars;
// Set the type of object
$Account->type = $feed['meta']['contact_object_name'];
$foreign_key_label = self::primary_key_id($feed);
try {
if (!self::$instance instanceof GFSalesforce) {
self::$instance = self::Instance();
}
// If the primary field has been set, use that to upsert instead of create.
// @since 2.5.2, to avoid duplicates at Salesforce
if (!empty($feed['meta']['primary_field'])) {
self::log_debug(sprintf('%s: Upserting using primary field of `%s`', __METHOD__, $feed['meta']['primary_field']));
if (empty(self::$instance->result->id)) {
// old upsert
// https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_upsert.htm
self::log_debug(__METHOD__ . ': Upserting');
$result = $api->upsert($feed['meta']['primary_field'], array($Account));
} else {
self::log_debug(sprintf('%s: Creating with previous id %s', __METHOD__, self::$instance->result->id));
$Account->fields[$feed['meta']['primary_field']] = self::$instance->result->id;
$result = $api->create(array($Account));
}
} else {
self::log_debug(__METHOD__ . ': Creating, not upserting');
$result = $api->create(array($Account));
}
$api_exception = '';
self::log_debug(sprintf('%s: $Account object: %s', __METHOD__, print_r($Account, true)));
} catch (Exception $e) {
self::log_error(sprintf("%s:\n\nException While Exporting Entry\nThere was an error exporting Entry #%s for Form #%s. Here's the error:\n%s", __METHOD__, $entry['id'], $form['id'], $e->getMessage()));
$api_exception = "\r\n\t\t\t\tException Message: " . $e->getMessage() . "\nFaultstring: " . $e->faultstring . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine() . "\nArgs: " . serialize($merge_vars) . "\nTrace: " . serialize($e->getTrace());
gform_update_meta($entry['id'], 'salesforce_api_result', 'Error: ' . $e->getMessage());
}
if (isset($result) && count($result) == 1 && !empty($result[0])) {
self::$instance->result = $result = $result[0];
}
if (isset($result->success) && !empty($result->success)) {
$result_id = $result->id;
self::$foreign_keys[$foreign_key_label] = $result_id;
gform_update_meta($entry['id'], 'salesforce_id', $result_id);
gform_update_meta($entry['id'], 'salesforce_api_result', 'success');
$success_note = sprintf(__('Successfully added/updated to Salesforce (%s) with ID #%s. View entry at %s', 'gravity-forms-salesforce'), $Account->type, $result_id, self::getTokenParam('instance_url') . '/' . $result_id);
self::log_debug(__METHOD__ . ': ' . $success_note);
self::add_note($entry["id"], $success_note);
self::admin_screen_message(__('Entry added/updated in Salesforce.', 'gravity-forms-salesforce'), 'updated');
/**
* @since 3.1.2
*/
do_action('gravityforms_salesforce_object_added_updated', $Account, $feed, $result_id);
return $result_id;
} else {
if (isset($result->errors[0])) {
$errors = $result->errors[0];
}
if (isset($errors)) {
self::log_error(sprintf('%s: There was an error exporting Entry #%s for Form #%s. Salesforce responded with:', __METHOD__, $entry['id'], $form['id']) . "\n" . print_r($errors, true));
if ($email = self::is_notify_on_error()) {
$error_heading = __('Error adding to Salesforce', 'gravity-forms-salesforce');
// Create the email message to send
$message = sprintf(apply_filters('gravityforms_salesforce_notify_on_error_message', '<h3>' . $error_heading . '</h3>' . wpautop(__("There was an error when attempting to add %sEntry #%s from the form \"%s\"", 'gravity-forms-salesforce')), $errors, $entry, $form), '<a href="' . admin_url('admin.php?page=gf_entries&view=entry&id=' . $entry['form_id'] . '&lid=' . $entry['id']) . '">', $entry['id'] . '</a>', $form['title']);
// Send as HTML
$headers = "Content-type: text/html; charset=" . get_option('blog_charset') . "\r\n";
// Send email
$sent = wp_mail($email, $error_heading, $message, $headers);
if (!$sent) {
self::log_error(__METHOD__ . ': There was an error sending the error email. This really isn\'t your day, is it?');
}
}
self::add_note($entry["id"], sprintf(__('Errors when adding to Salesforce (%s): %s', 'gravity-forms-salesforce'), $Account->type, $errors->message . $api_exception));
}
self::admin_screen_message(__('Errors when adding to Salesforce. Entry not sent! Check the Entry Notes below for more details.', 'gravity-forms-salesforce'), 'error');
return false;
}
}
示例13: process_renewals
public static function process_renewals()
{
if (!self::is_gravityforms_supported()) {
return;
}
// getting user information
$user_id = 0;
$user_name = "System";
//loading data lib
require_once self::get_base_path() . "/data.php";
// loading authorizenet api and getting credentials
self::include_api();
// getting all authorize.net subscription feeds
$recurring_feeds = GFAuthorizeNetData::get_feeds();
foreach ($recurring_feeds as $feed) {
// process renewalls if authorize.net feed is subscription feed
if ($feed["meta"]["type"] == "subscription") {
$form_id = $feed["form_id"];
// getting billig cycle information
$billing_cycle_number = $feed["meta"]["billing_cycle_number"];
$billing_cycle_type = $feed["meta"]["billing_cycle_type"];
if ($billing_cycle_type == "M") {
$billing_cycle = $billing_cycle_number . " month";
} else {
$billing_cycle = $billing_cycle_number . " day";
}
$querytime = strtotime(gmdate("Y-m-d") . "-" . $billing_cycle);
$querydate = gmdate("Y-m-d", $querytime) . " 00:00:00";
// finding leads with a late payment date
global $wpdb;
$results = $wpdb->get_results("SELECT l.id, l.transaction_id, m.meta_value as payment_date\r\n FROM {$wpdb->prefix}rg_lead l\r\n INNER JOIN {$wpdb->prefix}rg_lead_meta m ON l.id = m.lead_id\r\n WHERE l.form_id={$form_id}\r\n AND payment_status = 'Active'\r\n AND meta_key = 'subscription_payment_date'\r\n AND meta_value < '{$querydate}'");
foreach ($results as $result) {
//Getting entry
$entry_id = $result->id;
$entry = RGFormsModel::get_lead($entry_id);
//Getting subscription status from authorize.net
$subscription_id = $result->transaction_id;
$status_request = self::get_arb(self::get_local_api_settings($feed));
$status_response = $status_request->getSubscriptionStatus($subscription_id);
$status = $status_response->getSubscriptionStatus();
switch (strtolower($status)) {
case "active":
// getting feed trial information
$trial_period_enabled = $feed["meta"]["trial_period_enabled"];
$trial_period_occurrences = $feed["meta"]["trial_period_number"];
// finding payment date
$new_payment_time = strtotime($result->payment_date . "+" . $billing_cycle);
$new_payment_date = gmdate('Y-m-d H:i:s', $new_payment_time);
// finding payment amount
$payment_count = gform_get_meta($entry_id, "subscription_payment_count");
$new_payment_amount = gform_get_meta($entry_id, "subscription_regular_amount");
if ($trial_period_enabled == 1 && $trial_period_occurrences >= $payment_count) {
$new_payment_amount = gform_get_meta($entry_id, "subscription_trial_amount");
}
// update subscription payment and lead information
gform_update_meta($entry_id, "subscription_payment_count", $payment_count + 1);
gform_update_meta($entry_id, "subscription_payment_date", $new_payment_date);
RGFormsModel::add_note($entry_id, $user_id, $user_name, sprintf(__("Subscription payment has been made. Amount: %s. Subscriber Id: %s", "gravityforms"), GFCommon::to_money($new_payment_amount, $entry["currency"]), $subscription_id));
// inserting transaction
GFAuthorizeNetData::insert_transaction($entry_id, "payment", $subscription_id, $subscription_id, $new_payment_amount);
do_action("gform_authorizenet_post_recurring_payment", $subscription_id, $entry, $new_payment_amount, $payment_count);
//deprecated
do_action("gform_authorizenet_after_recurring_payment", $entry, $subscription_id, $subscription_id, $new_payment_amount);
break;
case "expired":
$entry["payment_status"] = "Expired";
RGFormsModel::update_lead($entry);
RGFormsModel::add_note($entry["id"], $user_id, $user_name, sprintf(__("Subscription has successfully completed its billing schedule. Subscriber Id: %s", "gravityformsauthorizenet"), $subscription_id));
do_action("gform_authorizenet_post_expire_subscription", $subscription_id, $entry);
//deprecated
do_action("gform_authorizenet_subscription_ended", $entry, $subscription_id, $transaction_id, $new_payment_amount);
break;
case "suspended":
$entry["payment_status"] = "Failed";
RGFormsModel::update_lead($entry);
RGFormsModel::add_note($entry["id"], $user_id, $user_name, sprintf(__("Subscription is currently suspended due to a transaction decline, rejection, or error. Suspended subscriptions must be reactivated before the next scheduled transaction or the subscription will be terminated by the payment gateway. Subscriber Id: %s", "gravityforms"), $subscription_id));
do_action("gform_authorizenet_post_suspend_subscription", $subscription_id, $entry);
//deprecated
do_action("gform_authorizenet_subscription_suspended", $entry, $subscription_id, $transaction_id, $new_payment_amount);
break;
case "terminated":
case "canceled":
self::cancel_subscription($entry);
RGFormsModel::add_note($entry_id, $user_id, $user_name, sprintf(__("Subscription has been canceled. Subscriber Id: %s", "gravityforms"), $subscription_id));
do_action("gform_authorizenet_post_cancel_subscription", $subscription_id, $entry);
//deprecated
do_action("gform_authorizenet_subscription_canceled", $entry, $subscription_id, $transaction_id, $new_payment_amount);
break;
default:
$entry["payment_status"] = "Failed";
RGFormsModel::update_lead($entry);
RGFormsModel::add_note($entry["id"], $user_id, $user_name, sprintf(__("Subscription is currently suspended due to a transaction decline, rejection, or error. Suspended subscriptions must be reactivated before the next scheduled transaction or the subscription will be terminated by the payment gateway. Subscriber Id: %s", "gravityforms"), $subscription_id));
do_action("gform_authorizenet_post_suspend_subscription", $subscription_id, $entry);
//deprecated
do_action("gform_authorizenet_subscription_suspended", $entry, $subscription_id, $transaction_id, $new_payment_amount);
break;
}
}
}
}
//.........这里部分代码省略.........
示例14: gravityforms_send_note_to_jdb
private function gravityforms_send_note_to_jdb($id = 0, $noteid = 0, $note = '')
{
$local_server = array('localhost', 'make.com', 'makerfaire.local', 'staging.makerfaire.com');
$remote_post_url = 'http://db.makerfaire.com/addExhibitNote';
if (isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], $local_server)) {
$remote_post_url = 'http://makerfaire.local/wp-content/allpostdata.php';
}
$encoded_array = http_build_query(array('CS_ID' => intval($id), 'note_id' => intval($noteid), 'note' => esc_attr($note)));
$post_body = array('method' => 'POST', 'timeout' => 45, 'headers' => array(), 'body' => $encoded_array);
// $res = wp_remote_post( 'http://makerfaire.local/wp-content/allpostdata.php', $post_body );
$res = wp_remote_post($remote_post_url, $post_body);
$er = 0;
if (200 == $res['response']['code']) {
$body = json_decode($res['body']);
if ('ERROR' != $body->status) {
$er = time();
}
// MySqli Insert Query
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
/*
* $synccontents = '"'.noteId.':'.$mysqli->real_escape_string($post_body).'"'; $syncresults = '"'.$mysqli->real_escape_string($body).'"'; $querytext= "INSERT INTO `wp_rg_lead_jdb_sync`(`lead_id`, `synccontents`, `jdb_response`) VALUES ($id,$encoded_array, $syncresults)"; $insert_row = $mysqli->query($querytext); if($insert_row){ print 'Success! Response from JDB was: ' .$results_on_send .'<br />'; }else{ die('Error : ('. $mysqli->errno .') '. $mysqli->error); };
*/
}
gform_update_meta($id, 'mf_jdb_add_note', $body);
return $er;
}
示例15: create
private function create($entry, $form, $feed, $api)
{
$merge_vars = array();
foreach ($feed["meta"]["field_map"] as $var_tag => $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$input_type = RGFormsModel::get_input_type($field);
if ($var_tag == 'address_full') {
$merge_vars[$var_tag] = self::get_address($entry, $field_id);
} else {
if ($var_tag == 'country') {
$merge_vars[$var_tag] = empty($entry[$field_id]) ? '' : GFCommon::get_country_code(trim($entry[$field_id]));
} else {
if ($entry[$field_id] === "0") {
$merge_vars[$var_tag] = "0";
} else {
if ($var_tag != "email") {
if (!empty($entry[$field_id]) && !($entry[$field_id] == "0")) {
switch ($input_type) {
case 'multiselect':
// If there are commas in the value, this makes it so it can be comma exploded.
// Values cannot contain semicolons: http://boards.developerforce.com/t5/NET-Development/Salesforce-API-inserting-values-into-multiselect-fields-using/td-p/125910
foreach ($field['choices'] as $choice) {
$entry[$field_id] = str_replace($choice, str_replace(',', ',', $choice), $entry[$field_id]);
}
// Break into an array
$elements = explode(",", $entry[$field_id]);
// We decode first so that the commas are commas again, then
// implode the array to be picklist format for SF
$merge_vars[$var_tag] = implode(';', array_map('html_entity_decode', array_map('htmlspecialchars', $elements)));
break;
default:
$merge_vars[$var_tag] = htmlspecialchars($entry[$field_id]);
}
} else {
// This is for checkboxes
$elements = array();
foreach ($entry as $key => $value) {
if (floor($key) == floor($field_id) && !empty($value)) {
$elements[] = htmlspecialchars($value);
}
}
$merge_vars[$var_tag] = implode(';', array_map('htmlspecialchars', $elements));
}
}
}
}
}
}
// Make sure the charset is UTF-8 for Salesforce.
$merge_vars = array_map(array('GFSalesforce', '_convert_to_utf_8'), $merge_vars);
// Don't send merge_vars that are empty. It can cause problems with Salesforce strict typing. For example,
// if the form has a text field where a number should go, but that number isn't always required, when it's
// not supplied, we don't want to send <var></var> to Salesforce. It might choke because it expects a Double
// data type, not an empty string
$merge_vars = array_filter($merge_vars, array('GFSalesforce', '_remove_empty_fields'));
$account = new SObject();
$account->fields = $merge_vars;
// Object type
$account->type = $feed['meta']['contact_object_name'];
try {
$result = $api->create(array($account));
$api_exception = '';
} catch (Exception $e) {
$api_exception = "\r\n Message: " . $e->getMessage() . "\nFaultstring: " . $e->faultstring . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine() . "\nArgs: " . serialize($merge_vars) . "\nTrace: " . serialize($e->getTrace());
}
$debug = '';
if (self::is_debug()) {
$debug = '<pre>' . print_r(array('Form Entry Data' => $entry, 'Form Meta Data' => $form, 'Salesforce Feed Meta Data' => $feed, 'Salesforce Posted Merge Data' => $merge_vars, 'Posted Data ($_POST)' => $_POST, 'result' => $result[0], '$api' => $api, '$api_exception' => $api_exception), true) . '</pre>';
}
if (isset($result[0]) && !empty($result[0]->success)) {
if (self::is_debug()) {
echo '<h2>Success</h2>' . $debug;
}
gform_update_meta($entry['id'], 'salesforce_id', $result[0]->id);
self::add_note($entry["id"], sprintf(__('Successfully added to Salesforce with ID #%s . View entry at %s', 'gravity-forms-salesforce'), $result[0]->id, 'https://na9.salesforce.com/' . $result[0]->id));
return $result[0]->id;
} else {
$errors = $result[0]->errors[0];
if (self::is_debug()) {
echo '<h2>Error</h2>' . $debug;
echo '<h2>Errors</h2><pre>' . print_r($errors, true) . '</pre>';
}
if ($email = self::is_notify_on_error()) {
$message = sprintf(apply_filters('gravityforms_salesforce_notify_on_error_message', __("<h3>Error Adding To Salesforce</h3><p>There was an error when attempting to add <a href='%s'>Entry #%s</a> from the form \"%s\"</p>", 'gravity-forms-salesforce'), $errors, $entry, $form), admin_url('admin.php?page=gf_entries&view=entry&id=' . $entry['form_id'] . '&lid=' . $entry['id']), $entry['id'], $form['title']);
$headers = "Content-type: text/html; charset=" . get_option('blog_charset') . "\r\n";
wp_mail($email, __('Error adding to Salesforce', 'gravity-forms-salesforce'), $message, $headers);
}
self::add_note($entry["id"], sprintf(__('Errors when adding to Salesforce: %s', 'gravity-forms-salesforce'), $errors->message . $api_exception));
return false;
}
}