本文整理汇总了PHP中GFAPI::update_entry方法的典型用法代码示例。如果您正苦于以下问题:PHP GFAPI::update_entry方法的具体用法?PHP GFAPI::update_entry怎么用?PHP GFAPI::update_entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFAPI
的用法示例。
在下文中一共展示了GFAPI::update_entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_post_content
function set_post_content($entry, $form)
{
//$headers[] = "Content-type: text/html";
$pending_meta_value = gform_get_meta($entry["id"], "is_pending");
if ($pending_meta_value == "1") {
// wp_mail('tim@automationlab.com.au', 'Form has been saved', print_r($entry, true), $headers);
$entry["orderStatus"] = "incomplete";
$output = GFAPI::update_entry($entry, $entry["id"]);
} else {
$entry["orderStatus"] = "complete";
$entry["unique_id"] = guid();
//wp_mail('tim@automationlab.com.au', 'Getting the Gravity Form Field IDs', print_r($entry, true), $headers);
//wp_mail('tim@automationlab.com.au', 'Getting the Gravity Form Data', print_r($form, true), $headers);
$output = GFAPI::update_entry($entry, $entry["id"]);
global $wpdb;
//look up row in lead table, update asic status and update with eCompanies order number.
$update = $wpdb->query($wpdb->prepare("UPDATE wp_rg_lead SET unique_id='" . $entry["unique_id"] . "' WHERE id=" . $entry['id'] . " AND form_id=" . $entry['form_id']));
// wp_mail('tim@automationlab.com.au', 'Getting the Gravity Form Field IDs', print_r($update, true), $headers);
}
}
示例2: pre_submission_handler
function pre_submission_handler($form)
{
if ($_SERVER["REDIRECT_URL"] == "/edit-page/") {
//submitted new values that need to be used to update the original entry via $success = GFAPI::update_entry( $entry );
//var_dump($_POST);
//Get original entry id
parse_str($_SERVER["QUERY_STRING"]);
//will be stored in $entry
//get the actual entry we want to edit
$editentry = GFAPI::get_entry($entry);
//make changes to it from new values in $_POST, this shows only the first field update
$editentry[1] = $_POST["input_1"];
//update it
$updateit = GFAPI::update_entry($editentry);
if (is_wp_error($updateit)) {
echo "Error.";
} else {
//success, so redirect
header("Location: http://domain.com/confirmation/");
}
//dont process and create new entry
die;
} else {
//any other code you want in this hook for regular entry submit
}
}
示例3: update_entry
/**
* Update entry
*
* @param array $entry
*/
public static function update_entry($entry)
{
/*
* GFFormsModel::update_lead() is no longer in use since version 1.8.8! Instead use GFAPI::update_entry().
*
* @see https://github.com/wp-premium/gravityforms/blob/1.8.13/forms_model.php#L587-L624
* @see https://github.com/wp-premium/gravityforms/blob/1.8.13/includes/api.php#L495-L654
* @see https://github.com/wp-premium/gravityforms/blob/1.8.7.11/forms_model.php#L587-L621
*/
if (Pronamic_WP_Pay_Class::method_exists('GFAPI', 'update_entry')) {
GFAPI::update_entry($entry);
} elseif (Pronamic_WP_Pay_Class::method_exists('GFFormsModel', 'update_lead')) {
GFFormsModel::update_lead($entry);
}
}
示例4: save
/**
* Save function stores class data as Wordpress meta data
* @return boolean true on success and false on failure
*
*/
public function save()
{
throw new NotImplementedException();
if (!defined('WPINC') || !$this->_post_id || !class_exists('GFAPI')) {
return false;
}
$lead = GFAPI::get_entry($this->_post_id);
$form = GFAPI::get_form($lead['form_id']);
$values = array();
foreach ($form['fields'] as $field) {
$key = $field['adminLabel'] ? $field['adminLabel'] : strtolower($field['label']);
$value = $lead[$field['id']];
$values[$key] = $value;
}
$success = GFAPI::update_entry($this->_data, $this->_post_id);
return $success;
}
示例5: put_entries
public function put_entries($data, $entry_id = null)
{
$this->authorize("gravityforms_edit_entries");
$result = empty($entry_id) ? GFAPI::update_entries($data) : ($result = GFAPI::update_entry($data, $entry_id));
if (is_wp_error($result)) {
$response = $this->get_error_response($result);
$status = $this->get_error_status($result);
} else {
$status = 200;
$response = empty($entry_id) ? __("Entries updated successfully", "gravityforms") : __("Entry updated successfully", "gravityforms");
}
$this->end($status, $response);
}
示例6: start_subscription
/**
* Used to start a new subscription. Updates the associcated entry with the payment and transaction details and adds an entry note.
*
* @param [array] $entry Entry object
* @param [string] $subscription_id ID of the subscription
* @param [float] $amount Numeric amount of the initial subscription payment
*
* @return [array] $entry Entry Object
*/
public function start_subscription($entry, $subscription)
{
$this->log_debug(__METHOD__ . '(): Processing request.');
if (!$this->has_subscription($entry)) {
$entry['payment_status'] = 'Active';
$entry['payment_amount'] = $subscription['amount'];
$entry['payment_date'] = gmdate('y-m-d H:i:s');
$entry['transaction_id'] = $subscription['subscription_id'];
$entry['transaction_type'] = '2';
// subscription
$entry['is_fulfilled'] = '1';
$result = GFAPI::update_entry($entry);
$this->add_note($entry['id'], sprintf(esc_html__('Subscription has been created. Subscription Id: %s.', 'gravityforms'), $subscription['subscription_id']), 'success');
/**
* Fires when someone starts a subscription
*
* @param array $entry Entry Object
* @param array $subscription The new Subscription object
*/
do_action('gform_post_subscription_started', $entry, $subscription);
if (has_filter('gform_post_subscription_started')) {
$this->log_debug(__METHOD__ . '(): Executing functions hooked to gform_post_subscription_started.');
}
$subscription['type'] = 'create_subscription';
$this->post_payment_action($entry, $subscription);
}
return $entry;
}
示例7: start_subscription
/**
* Used to start a new subscription. Updates the associcated entry with the payment and transaction details and adds an entry note.
*
* @param [array] $entry Entry object
* @param [string] $subscription_id ID of the subscription
* @param [float] $amount Numeric amount of the initial subscription payment
* @return [bool] $result
*/
public function start_subscription($entry, $subscription)
{
$entry['payment_status'] = 'Active';
$entry['payment_amount'] = $subscription['amount'];
$entry['payment_date'] = gmdate('y-m-d H:i:s');
$entry['transaction_id'] = $subscription['subscription_id'];
$entry['transaction_type'] = '2';
// subscription
$entry['is_fulfilled'] = true;
$result = GFAPI::update_entry($entry);
$this->add_note($entry['id'], sprintf(__('Subscription has been created. Subscriber Id: %s.', 'gravityforms'), $subscription['subscription_id']));
}
示例8: maybe_update_post_fields
/**
* Loop through the fields being edited and if they include Post fields, update the Entry's post object
*
* @param array $form Gravity Forms form
*
* @return void
*/
function maybe_update_post_fields($form)
{
$post_id = $this->entry['post_id'];
// Security check
if (false === GVCommon::has_cap('edit_post', $post_id)) {
do_action('gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id);
return;
}
$update_entry = false;
$updated_post = $original_post = get_post($post_id);
foreach ($this->entry as $field_id => $value) {
//todo: only run through the edit entry configured fields
$field = RGFormsModel::get_field($form, $field_id);
if (class_exists('GF_Fields')) {
$field = GF_Fields::create($field);
}
if (GFCommon::is_post_field($field)) {
// Get the value of the field, including $_POSTed value
$value = RGFormsModel::get_field_value($field);
// Convert the field object in 1.9 to an array for backward compatibility
$field_array = GVCommon::get_field_array($field);
switch ($field_array['type']) {
case 'post_title':
case 'post_content':
case 'post_excerpt':
$updated_post->{$field_array['type']} = $value;
break;
case 'post_tags':
wp_set_post_tags($post_id, $value, false);
break;
case 'post_category':
$categories = is_array($value) ? array_values($value) : (array) $value;
$categories = array_filter($categories);
wp_set_post_categories($post_id, $categories, false);
// prepare value to be saved in the entry
$field = GFCommon::add_categories_as_choices($field, '');
// if post_category is type checkbox, then value is an array of inputs
if (isset($value[strval($field_id)])) {
foreach ($value as $input_id => $val) {
$input_name = 'input_' . str_replace('.', '_', $input_id);
$this->entry[strval($input_id)] = RGFormsModel::prepare_value($form, $field, $val, $input_name, $this->entry['id']);
}
} else {
$input_name = 'input_' . str_replace('.', '_', $field_id);
$this->entry[strval($field_id)] = RGFormsModel::prepare_value($form, $field, $value, $input_name, $this->entry['id']);
}
break;
case 'post_custom_field':
$input_type = RGFormsModel::get_input_type($field);
$custom_field_name = $field_array['postCustomFieldName'];
// Only certain custom field types are supported
if (!in_array($input_type, array('list', 'fileupload'))) {
update_post_meta($post_id, $custom_field_name, $value);
}
break;
case 'post_image':
$value = '';
break;
}
//ignore fields that have not changed
if ($value === rgget((string) $field_id, $this->entry)) {
continue;
}
// update entry
if ('post_category' !== $field->type) {
$this->entry[strval($field_id)] = $value;
}
$update_entry = true;
}
}
if ($update_entry) {
$return_entry = GFAPI::update_entry($this->entry);
if (is_wp_error($return_entry)) {
do_action('gravityview_log_error', 'Updating the entry post fields failed', $return_entry);
} else {
do_action('gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded');
}
}
$return_post = wp_update_post($updated_post, true);
if (is_wp_error($return_post)) {
do_action('gravityview_log_error', 'Updating the post content failed', $return_post);
} else {
do_action('gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded');
}
}
示例9: maybe_delete_entry
/**
* Delete entries
* This function is used to delete entries with an ajax request
* Could use better (or at least some) error handling
*/
public function maybe_delete_entry()
{
if (isset($_POST["mode"]) && $_POST["mode"] == "delete" && isset($_POST["delete_id"]) && isset($_POST["form_id"])) {
$form_id = $_POST["form_id"];
$form = GFAPI::get_form($form_id);
$settings = $this->get_form_settings($form);
$enable_delete = $settings["enable_delete"];
$delete_type = $settings["delete_type"];
if ($enable_delete) {
$delete_id = $_POST["delete_id"];
$entry = GFAPI::get_entry($delete_id);
if (!is_wp_error($entry)) {
if ($entry["created_by"] == $this->stickylist_get_current_user() || current_user_can('delete_others_posts') || current_user_can('stickylist_delete_entries')) {
if ($_POST["delete_post_id"] != null) {
$delete_post_id = $_POST["delete_post_id"];
} else {
$delete_post_id = "";
}
if ($delete_type == "trash") {
$entry["status"] = "trash";
$success = GFAPI::update_entry($entry, $delete_id);
if ($delete_post_id != "") {
wp_delete_post($delete_post_id, false);
}
}
if ($delete_type == "permanent") {
$success = GFAPI::delete_entry($delete_id);
if ($delete_post_id != "") {
wp_delete_post($delete_post_id, true);
}
}
if ($success) {
$notifications = $form["notifications"];
$notification_ids = array();
foreach ($notifications as $notification) {
$notification_type = $notification["stickylist_notification_type"];
if ($notification_type == "delete" || $notification_type == "all") {
$id = $notification["id"];
array_push($notification_ids, $id);
}
}
GFCommon::send_notifications($notification_ids, $form, $entry);
}
}
}
}
}
}
示例10: process_capture
protected function process_capture($authorization, $feed, $submission_data, $form, $entry)
{
$payment = rgar($authorization, "captured_payment");
if (empty($payment)) {
return;
}
if ($payment["is_success"]) {
$entry["transaction_id"] = $payment["transaction_id"];
$entry["transaction_type"] = "1";
$entry["is_fulfilled"] = true;
$entry["currency"] = GFCommon::get_currency();
$entry["payment_amount"] = $payment["amount"];
$entry["payment_status"] = "Paid";
$entry["payment_date"] = gmdate("Y-m-d H:i:s");
$entry["payment_method"] = $payment["payment_method"];
$this->insert_transaction($entry["id"], "payment", $entry["transaction_id"], $entry["payment_amount"]);
GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Payment has been captured successfully. Amount: %s. Transaction Id: %s", "gravityforms"), GFCommon::to_money($payment["amount"], $entry["currency"]), $payment["transaction_id"]));
} else {
$entry["payment_status"] = "Failed";
GFFormsModel::add_note($entry["id"], 0, "System", sprintf(__("Payment failed to be captured. Reason: %s", "gravityforms"), $payment["error_message"]));
}
GFAPI::update_entry($entry);
return $entry;
}
示例11: sticky_set_post_content
function sticky_set_post_content($entry, $form)
{
if ($form['isSticky']) {
if (is_user_logged_in()) {
$saved_option_key = sticky_getEntryOptionKeyForGF($form);
$saved_option_value = get_option($saved_option_key);
// Save the entry ID in wp_options if this is the first time the form is submitted by this user.
// If we dont have a saved value, we save the entry ID
if (!$saved_option_value) {
update_option($saved_option_key, $entry['id']);
//If we have a saved value, update and delete
} else {
// ...as long as the form doesnt allow multiple entries...
if (!$form['isEnableMulipleEntry']) {
// We dont want to loose our starred and read status when we update
$original_entry = RGFormsModel::get_lead($saved_option_value);
$entry["is_starred"] = $original_entry["is_starred"];
// ...unless the user wants us to
if (!isset($form['isMarkUnread'])) {
$entry["is_read"] = $original_entry["is_read"];
}
$success = GFAPI::update_entry($entry, $saved_option_value);
$success = GFAPI::delete_entry($entry["id"]);
// ...and if it does, dont delete or update but save the new entry ID instead so that the sticky form is populated with the latest saved entry.
} else {
update_option($saved_option_key, $entry['id']);
}
}
}
}
}
示例12: update_object
/**
* @param $object
* @param $fields
*
* @return mixed
*/
function update_object($entry_id = '', $entry = array())
{
return GFAPI::update_entry($entry_id, $entry);
}
示例13: gformEntryPostSave
/**
* form entry post-submission processing
* @param array $entry
* @param array $form
* @return array
*/
public function gformEntryPostSave($entry, $form)
{
if (!empty($this->txResult['payment_status'])) {
foreach ($this->txResult as $key => $value) {
switch ($key) {
case 'payment_status':
case 'payment_date':
case 'payment_amount':
case 'transaction_id':
case 'transaction_type':
case 'payment_gateway':
// custom entry meta must be saved with entry
// custom entry meta must be saved with entry
case 'authcode':
// custom entry meta must be saved with entry
// update entry
$entry[$key] = $value;
break;
default:
// update entry meta
gform_update_meta($entry['id'], $key, $value);
break;
}
}
// update the entry
if (class_exists('GFAPI')) {
GFAPI::update_entry($entry);
} else {
GFFormsModel::update_lead($entry);
}
}
return $entry;
}
示例14: gfee_after_submission
function gfee_after_submission($tmp_entry, $form)
{
// get the original entry we want to edit/update
GFEE::set_entry_id($_POST['gfee_entry_id']);
// NEED TO BEEF UP SECURITY HERE AS THIS VALUE CAN BE MODIFIED BY USER TO EDIT SOMEONE ELSE'S ENTRY
$orig_entry_id = GFEE::$entry_id;
$orig_entry = GFAPI::get_entry($orig_entry_id);
// initialize deletefiles variable
$deletefiles = array();
// take care of certain fields that need special handling
foreach ($form['fields'] as $field) {
// don't touch admin-only fields since front-end can't modify those
if (!$field['adminOnly']) {
// handle file uploads
if ($field['type'] == 'fileupload') {
// if user has deleted this file upload, save to list to delete later
if ($_POST['delete_file'] == $field['id']) {
$delete_file_path = get_file_path_from_gf_entry($orig_entry[$field['id']]);
$deletefiles[] = $delete_file_path;
// save new file upload field data
$orig_entry[$field['id']] = $tmp_entry[$field['id']];
}
// this currently only supports one file per field
if ($tmp_entry[$field['id']]) {
// new file(s) uploaded, we need to copy the files because the originals will be deleted with the temp entry by Gravity Forms
$file_path = get_file_path_from_gf_entry($tmp_entry[$field['id']]);
$tmp_file_path = $file_path . '.tmp';
copy($file_path, $tmp_file_path);
// save new file upload field data
$orig_entry[$field['id']] = $tmp_entry[$field['id']];
}
// handle checkboxes, address, and name fields
} elseif ($field['type'] == 'checkbox' || $field['type'] == 'address' || $field['type'] == 'name') {
foreach ($field->inputs as $key => $input) {
// loop each field input and save it
$orig_entry[strval($input['id'])] = $tmp_entry[strval($input['id'])];
}
} else {
// save updated field data to original entry
$orig_entry[$field['id']] = $tmp_entry[$field['id']];
}
}
}
// perform update entry with original entry data fields updated
$update_success = GFAPI::update_entry($orig_entry);
if ($update_success === true) {
// delete temporary entry
$delete_success = GFAPI::delete_entry($tmp_entry['id']);
// delete any lingering files that shouldn't be around anymore
foreach ($deletefiles as $filename) {
if (file_exists($filename)) {
unlink($filename);
}
}
// original file(s) should be deleted by Gravity Forms or us, need to rename temp file back to original name
if ($tmp_file_path) {
rename($tmp_file_path, $file_path);
}
}
}
示例15: maybe_update_post_fields
/**
* Loop through the fields being edited and if they include Post fields, update the Entry's post object
*
* @param array $form Gravity Forms form
*
* @return void
*/
private function maybe_update_post_fields($form)
{
$post_id = $this->entry['post_id'];
// Security check
if (false === GVCommon::has_cap('edit_post', $post_id)) {
do_action('gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id);
return;
}
$update_entry = false;
$updated_post = $original_post = get_post($post_id);
foreach ($this->entry as $field_id => $value) {
$field = RGFormsModel::get_field($form, $field_id);
if (!$field) {
continue;
}
if (GFCommon::is_post_field($field) && 'post_category' !== $field->type) {
// Get the value of the field, including $_POSTed value
$value = RGFormsModel::get_field_value($field);
// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
$entry_tmp = $this->entry;
$entry_tmp["{$field_id}"] = $value;
switch ($field->type) {
case 'post_title':
$post_title = $value;
if (rgar($form, 'postTitleTemplateEnabled')) {
$post_title = $this->fill_post_template($form['postTitleTemplate'], $form, $entry_tmp);
}
$updated_post->post_title = $post_title;
$updated_post->post_name = $post_title;
unset($post_title);
break;
case 'post_content':
$post_content = $value;
if (rgar($form, 'postContentTemplateEnabled')) {
$post_content = $this->fill_post_template($form['postContentTemplate'], $form, $entry_tmp, true);
}
$updated_post->post_content = $post_content;
unset($post_content);
break;
case 'post_excerpt':
$updated_post->post_excerpt = $value;
break;
case 'post_tags':
wp_set_post_tags($post_id, $value, false);
break;
case 'post_category':
break;
case 'post_custom_field':
if (!empty($field->customFieldTemplateEnabled)) {
$value = $this->fill_post_template($field->customFieldTemplate, $form, $entry_tmp, true);
}
$input_type = RGFormsModel::get_input_type($field);
// Only certain custom field types are supported
switch ($input_type) {
case 'fileupload':
case 'list':
case 'multiselect':
if (!is_string($value)) {
$value = function_exists('wp_json_encode') ? wp_json_encode($value) : json_encode($value);
}
// break; left intentionally out
// break; left intentionally out
default:
update_post_meta($post_id, $field->postCustomFieldName, $value);
}
break;
case 'post_image':
$value = $this->update_post_image($form, $field, $field_id, $value, $this->entry, $post_id);
break;
}
// update entry after
$this->entry["{$field_id}"] = $value;
$update_entry = true;
unset($entry_tmp);
}
}
if ($update_entry) {
$return_entry = GFAPI::update_entry($this->entry);
if (is_wp_error($return_entry)) {
do_action('gravityview_log_error', 'Updating the entry post fields failed', array('$this->entry' => $this->entry, '$return_entry' => $return_entry));
} else {
do_action('gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded');
}
}
$return_post = wp_update_post($updated_post, true);
if (is_wp_error($return_post)) {
$return_post->add_data($updated_post, '$updated_post');
do_action('gravityview_log_error', 'Updating the post content failed', compact('updated_post', 'return_post'));
} else {
do_action('gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post);
}
}