本文整理汇总了PHP中GFAPI类的典型用法代码示例。如果您正苦于以下问题:PHP GFAPI类的具体用法?PHP GFAPI怎么用?PHP GFAPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GFAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($arguments)
{
if (class_exists('RGFormsModel') && is_callable(array('RGFormsModel', 'get_form_meta')) && class_exists('GFAPI') && is_callable(array('GFAPI', 'get_entries'))) {
if (empty($arguments['id'])) {
return array('error' => 'Form ID Required');
}
$return = array();
$form_meta = GFFormsModel::get_form_meta(absint($arguments['id']));
$return['field_labels'] = array();
foreach ($form_meta['fields'] as $field) {
$return['field_labels']["{$field['id']}"] = $this->_process_label($field);
}
$return['current_page'] = empty($arguments['page']) ? 1 : absint($arguments['page']);
if ($return['current_page'] < 1) {
$return['current_page'] = 1;
}
$paging = array('page_size' => 20);
$paging['offset'] = ($return['current_page'] - 1) * $paging['page_size'];
$return['total_count'] = 0;
$return['entries'] = GFAPI::get_entries(absint($arguments['id']), null, null, $paging, $return['total_count']);
$return['page_size'] = $paging['page_size'];
$return['total_pages'] = ceil($return['total_count'] / $paging['page_size']);
return $return;
}
return false;
}
示例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: admin_menu
public static function admin_menu()
{
$tribe_settings = TribeSettings::instance();
// Export entries
if ($_REQUEST['page'] === 'tribe-events-calendar-registration-export' and !is_null($_REQUEST['id'])) {
$post_id = $_REQUEST['id'];
$forms = GFFormsModel::get_forms();
foreach ($forms as $form) {
if (strtolower($form->title) == strtolower(self::$formTitle)) {
$form_id = $form->id;
$entries = GFAPI::get_entries($form_id, array('field_filters' => array(array('key' => '7', 'value' => $post_id))), null, array('offset' => '0', 'page_size' => '1000'));
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=" . sanitize_title_with_dashes($entries[0]['6']) . ".csv");
header("Pragma: no-cache");
header("Expires: 0");
echo $entries[0]['6'] . "\n";
echo "Date Created, First Name, Last Name, Email, Phone Number, Number of Participants\n";
foreach ($entries as $entry) {
echo $entry['date_created'] . ',';
echo $entry['1'] . ',';
echo $entry['2'] . ',';
echo $entry['3'] . ',';
echo $entry['4'] . ',';
echo $entry['5'] . "\n";
}
die;
}
}
}
}
示例4: update_user
/**
* Update the WordPress user profile based on the GF User Registration create feed
*
* @since 1.11
*
* @param array $form Gravity Forms form array
* @param string $entry_id Gravity Forms entry ID
* @return void
*/
public function update_user($form = array(), $entry_id = 0)
{
if (!class_exists('GFAPI') || !class_exists('GFUser') || empty($entry_id)) {
return;
}
$entry = GFAPI::get_entry($entry_id);
/**
* @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
* @since 1.11
* @param array $entry Gravity Forms entry
* @param array $form Gravity Forms form
*/
$entry = apply_filters('gravityview/edit_entry/user_registration/entry', $entry, $form);
/**
* @since 1.14
*/
$config = GFUser::get_active_config($form, $entry);
/**
* @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
* @since 1.14
* @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
* @param[in] array $form Gravity Forms form array
* @param[in] array $entry Gravity Forms entry being edited
*/
$config = apply_filters('gravityview/edit_entry/user_registration/config', $config, $form, $entry);
$this->_user_before_update = get_userdata($entry['created_by']);
// The priority is set to 3 so that default priority (10) will still override it
add_filter('send_password_change_email', '__return_false', 3);
add_filter('send_email_change_email', '__return_false', 3);
// Trigger the User Registration update user method
GFUser::update_user($entry, $form, $config);
remove_filter('send_password_change_email', '__return_false', 3);
remove_filter('send_email_change_email', '__return_false', 3);
}
示例5: aria_add_song_from_csv
/**
* This function adds a new entry (from a .csv file) obtained via GF.
*
*/
function aria_add_song_from_csv($entry, $form)
{
// locate the name of the song file
$filename_url = $entry["4"];
//echo "Filename (url) is: " . $filename_url;
$filename_atomic_strings = explode("/", $filename_url);
$filename = "/var/www/html/wp-content/uploads/testpath/";
$filename .= $filename_atomic_strings[count($filename_atomic_strings) - 1];
//echo "<br> Filename is: " . $filename;
$song_data = array();
if (($file_ptr = fopen($filename, "r")) !== FALSE) {
while (($data = fgetcsv($file_ptr, 1000, ";")) !== FALSE) {
// no image
if (count($data) === 4) {
$song_data[] = array("1" => "{$data['0']}", "2" => $data[1], "3" => $data[2], "4" => $data[3]);
} else {
$song_data[] = array("1" => $data[0], "2" => $data[1], "3" => $data[2], "4" => $data[3], "5" => $data[4]);
}
/*
for ($i = 0; $i < count($data); $i++) {
echo $data[$i] . "</br>";
}
unset($data); */
}
}
/*
print_r($song_data);
die;
*/
$newly_added_entry_ids = GFAPI::add_entries($song_data, 38);
// remove filename from upload folder
unlink($filename);
}
示例6: cgc_contest_get_entries
function cgc_contest_get_entries($id = 0, $url = '', $limit = '')
{
$paging = array('offset' => 0, 'page_size' => 100);
// get entries via GF api with entry id
$entries = GFAPI::get_entries($id, '', null, $paging);
// bail if no data
if (!$id || !$url) {
return;
}
if (!$entries) {
echo 'No entries yet, be the first to enter by submitting your entry above!';
}
$i = 0;
foreach ($entries as $entry) {
$i++;
// bail if no url in entry
if (empty($entry[$url])) {
return;
}
// get the sketchfab url from the entry and build the iframe url
$source = $entry[$url] ? sprintf('%s/embed', $entry[$url]) : null;
// add a class to every 3rd
if (0 == $i % 3) {
$last = 'last';
} else {
$last = null;
}
// draw the item
printf('<div class="cgc-contest-entry %s"><div class="cgc-contest-entry-inner"><iframe width="310" height="230" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="%s" onload=lzld(this) frameborder="0" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe></div></div>', $last, $source);
// if a limit is set then break at the set limit
if ($limit && 0 == $i % $limit) {
break;
}
}
}
示例7: aria_upload_songs
function aria_upload_songs()
{
// find sheet music file
//$sheet_music_csv = plugin_dir_path(__FILE__) . "../uploads/musictestsheet.csv";
$sheet_music_csv = "/var/www/html/wp-content/uploads/musicsheettest.csv";
// read fiile and parse csv content
$song_data = array();
if (($file_ptr = fopen($sheet_music_csv, "r")) !== FALSE) {
while (($data = fgetcsv($file_ptr, 1000, ";")) !== FALSE) {
// no image
if (count($data) === 4) {
$song_data[] = array("1" => "{$data['0']}", "2" => $data[1], "3" => $data[2], "4" => $data[3]);
} else {
$song_data[] = array("1" => $data[0], "2" => $data[1], "3" => $data[2], "4" => $data[3], "5" => $data[4]);
}
/*
for ($i = 0; $i < count($data); $i++) {
echo $data[$i] . "</br>";
}
unset($data); */
}
}
/*
print_r($song_data);
die;
*/
$newly_added_entry_ids = GFAPI::add_entries($song_data, 38);
}
示例8: add_form_fields
/**
* If a form has list fields, add the columns to the field picker
*
* @since 1.17
*
* @param array $fields Associative array of fields, with keys as field type
* @param array $form GF Form array
* @param bool $include_parent_field Whether to include the parent field when getting a field with inputs
*
* @return array $fields with list field columns added, if exist. Unmodified if form has no list fields.
*/
function add_form_fields($fields = array(), $form = array(), $include_parent_field = true)
{
$list_fields = GFAPI::get_fields_by_type($form, 'list');
// Add the list columns
foreach ($list_fields as $list_field) {
if (empty($list_field->enableColumns)) {
continue;
}
$list_columns = array();
foreach ((array) $list_field->choices as $key => $input) {
$input_id = sprintf('%d.%d', $list_field->id, $key);
// {field_id}.{column_key}
$list_columns[$input_id] = array('label' => rgar($input, 'text'), 'customLabel' => '', 'parent' => $list_field, 'type' => rgar($list_field, 'type'), 'adminLabel' => rgar($list_field, 'adminLabel'), 'adminOnly' => rgar($list_field, 'adminOnly'));
}
// If there are columns, add them under the parent field
if (!empty($list_columns)) {
$index = array_search($list_field->id, array_keys($fields)) + 1;
/**
* Merge the $list_columns into the $fields array at $index
* @see https://stackoverflow.com/a/1783125
*/
$fields = array_slice($fields, 0, $index, true) + $list_columns + array_slice($fields, $index, null, true);
}
unset($list_columns, $index, $input_id);
}
return $fields;
}
示例9: post_entries_assignees
/**
* Processes a status update for a specified assignee of the current step of the specified entry.
*
* @param $entry_id
* @param string $assignee_key
*/
function post_entries_assignees($entry_id, $assignee_key = null)
{
global $HTTP_RAW_POST_DATA;
$capability = apply_filters('gravityflow_web_api_capability_post_entries_assignees', 'gravityflow_create_steps');
$this->authorize($capability);
if (empty($assignee_key)) {
$this->end(400, 'Bad request');
}
$entry = GFAPI::get_entry($entry_id);
if (empty($entry)) {
$this->end(404, 'Entry not found');
}
$form_id = absint($entry['form_id']);
$api = new Gravity_Flow_API($form_id);
$step = $api->get_current_step($entry);
$assignee = new Gravity_Flow_Assignee($assignee_key, $step);
if (!isset($HTTP_RAW_POST_DATA)) {
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
$data = json_decode($HTTP_RAW_POST_DATA, true);
$new_status = $data['status'];
$form = GFAPI::get_form($form_id);
$step->process_assignee_status($assignee, $new_status, $form);
$api->process_workflow($entry_id);
$response = 'Status updated successfully';
$this->end(200, $response);
}
示例10: set_post_categories
/**
* Update the post categories based on all post category fields
*
* @since 1.17
*
* @param array $form Gravity Forms form array
* @param int $entry_id Numeric ID of the entry that was updated
*
* @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
*/
public function set_post_categories($form = array(), $entry_id = 0)
{
$entry = GFAPI::get_entry($entry_id);
$post_id = rgar($entry, 'post_id');
if (empty($post_id)) {
return false;
}
$return = false;
$post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
if ($post_category_fields) {
$updated_categories = array();
foreach ($post_category_fields as $field) {
// Get the value of the field, including $_POSTed value
$field_cats = RGFormsModel::get_field_value($field);
$field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
$field_cats = gv_map_deep($field_cats, 'intval');
$updated_categories = array_merge($updated_categories, array_values($field_cats));
}
// Remove `0` values from intval()
$updated_categories = array_filter($updated_categories);
/**
* @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
* @since 1.17
* @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
*/
$append = apply_filters('gravityview/edit_entry/post_categories/append', false);
$return = wp_set_post_categories($post_id, $updated_categories, $append);
}
return $return;
}
示例11: aura_get_master_aura_form_details
function aura_get_master_aura_form_details($form, $ajax_enabled, $field_values)
{
// Get details from master form.
$ar_form = GFAPI::get_form(1);
$au_search_criteria = array('status' => array('active', 'trash'));
$ar_entries = GFAPI::get_entries(1, $au_search_criteria);
$body_part = array();
// To hold description associated with bodypart/color.
$pos_color = array();
$neg_color = array();
$bp = array();
// Pull details from aura details form to display in this form.
// Index each entry by 'body part'
foreach ($ar_entries as $entry) {
if ($entry['1'] == '') {
continue;
} else {
$idx = $entry['1'];
$bp[] = array('text' => $entry['1'], 'value' => $entry['1']);
if ($entry['2'] != '') {
$body_part[$idx]['pos_color'][$entry['2']] = $entry['4'];
// Set pos colour value to description
$needle = array('text' => $entry['2'], 'value' => $entry['2']);
if (!in_array($needle, $pos_color)) {
$pos_color[] = $needle;
}
}
if ($entry['3'] != '') {
$body_part[$idx]['neg_color'][$entry['3']] = $entry['5'];
$needle = array('text' => $entry['3'], 'value' => $entry['3']);
if (!in_array($needle, $neg_color)) {
$neg_color[] = $needle;
}
}
}
}
// To display description using JS
$json_bp = json_encode($body_part);
/*
$html =
'<input type="hidden" name="aura_body_part"' .
'id="aura_body_part_id"' .
'value=' . $json_bp .
' />' ;
*/
// HACK/REVISIT: Creating JS var safe?
$html = '<script type="text/javascript"> var g_aura_body_part=' . $json_bp . '</script>';
echo $html;
$form['fields'][5]['choices'] = $bp;
$form['fields'][6]['choices'] = $pos_color;
$form['fields'][8]['choices'] = $neg_color;
// Default display
$form['fields'][5]['placeholder'] = 'Pick choice from list below';
$form['fields'][6]['placeholder'] = 'Pick choice from list below';
$form['fields'][8]['placeholder'] = 'Pick choice from list below';
// $form['fields'][7]['choices'] = $pos_color_descr;
// $form['fields'][9]['choices'] = $neg_color_descr;
return $form;
}
示例12: update_entry_property
/**
* Update entry property
*
* @param int $entry_id Entry ID
* @param string $property Name of the property to update
* @param string $value Value for the property
*/
public static function update_entry_property($entry_id, $property, $value)
{
if (Pronamic_WP_Pay_Class::method_exists('GFAPI', 'update_entry_property')) {
GFAPI::update_entry_property($entry_id, $property, $value);
} elseif (Pronamic_WP_Pay_Class::method_exists('GFFormsModel', 'update_lead_property')) {
GFFormsModel::update_lead_property($entry_id, $property, $value);
}
}
示例13: get_entry
/**
* Fetch the entry for the View
*
* We need to use this instead of GFAPI::get_entry() because we want to also pass the Form ID to the
* get_entries() method.
*
* @param int $entry_id
* @param int $form_id
*
* @return array|bool False if no entry exists; Entry array if exists.
*/
function get_entry($entry_id = 0, $form_id = 0)
{
$search_criteria = array('field_filters' => array(array('key' => 'id', 'value' => $entry_id)));
$paging = array('offset' => 0, 'page_size' => 1);
$entries = GFAPI::get_entries($form_id, $search_criteria, null, $paging);
$entry = !is_wp_error($entries) && !empty($entries[0]) ? $entries[0] : false;
return $entry;
}
示例14: get_this_field_value_entry_list
public function get_this_field_value_entry_list($value, $form_id, $field_id, $entry)
{
$form = GFAPI::get_form($form_id);
$field = GFFormsmodel::get_field($form, $field_id);
if ($this->is_this_field_type($field)) {
$value = $this->get_value_entry_list($value, $form_id, $field_id, $entry);
}
return $value;
}
示例15: prevent_entry_submission_save
function prevent_entry_submission_save($entry, $form)
{
$form_id = $entry['form_id'];
$forms_id = array(1, 2, 3, 4, 5, 6, 7, 8);
/*the Id's you want entry not be save*/
if (in_array($form_id, $forms_id)) {
GFAPI::delete_entry($entry['id']);
}
}