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
    }
}
 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;
 }
Exemple #3
1
 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;
             }
         }
     }
 }
function getEntries($formID)
{
    if (class_exists("GFForms")) {
        $paging = array('offset' => 0, 'page_size' => 200);
        $sorting = array();
        $total_count = 0;
        $search_criteria = array();
        $unfilteredEntries = GFAPI::get_entries(5, $search_criteria, $sorting, $paging, $total_count);
        $filteredEntries = array();
        foreach ($unfilteredEntries as $value) {
            array_push($filteredEntries, iff_competition_filterEntry($value));
        }
        return $filteredEntries;
    }
    return null;
}
 /**
  * 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);
 }
/**
 * 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);
}
Exemple #7
0
 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;
         }
     }
 }
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);
}
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
Exemple #12
0
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;
}
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
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']);
    }
}
Exemple #16
0
 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;
 }
 function feed_settings_fields()
 {
     if (is_numeric($_GET['id'])) {
         $feed_form_id = $_GET['id'];
         $form = GFAPI::get_form($feed_form_id);
     }
     $args = array('field_types' => array(), 'input_types' => array('text', 'name', 'email'), 'callback' => false);
     $fields = GFAddOn::get_form_fields_as_choices($form, $args);
     return array(array('title' => 'Postmatic', 'fields' => array(array('name' => 'feed_name', 'label' => 'Feed Name', 'type' => 'text'), array('name' => 'first_name', 'label' => 'First Name Field', 'type' => 'select', 'choices' => $fields), array('name' => 'last_name', 'label' => 'Last Name Field', 'type' => 'select', 'choices' => $fields), array('name' => 'email', 'label' => 'Email Field', 'type' => 'select', 'choices' => $fields, 'required' => true), array('name' => 'condition', 'tooltip' => "Configure the event that riggers the user to be subscribed to your Postmatic feed.", 'label' => 'Condition', 'type' => 'feed_condition', 'checkbox_label' => 'Enable condition for this subscription', 'instructions' => 'Subscribe this user if'))));
 }
Exemple #18
0
/**
 * On CAP Byline activation run these actions
 */
function cap_byline_activate()
{
    /**
     * Create the Gravity Form contact form for bios
     */
    if (function_exists('gform_notification')) {
        $form = array('labelPlacement' => 'top_label', 'useCurrentUserAsAuthor' => 1, 'title' => __('Contact Author', 'cap-byline'), 'description' => __('Fill out the form below to contact this author', 'cap-byline'), 'descriptionPlacement' => 'below', 'button' => array('type' => 'text', 'text' => __('Submit', 'cap-byline')), 'fields' => array('0' => array('id' => '1', 'isRequired' => '1', 'size' => 'medium', 'type' => 'name', 'label' => __('Name', 'cap-byline'), 'inputs' => array('0' => array('id' => '1.3', 'label' => __('First', 'cap-byline')), '1' => array('id' => '1.6', 'label' => __('Last', 'cap-byline'))), 'formId' => '2', 'pageNumber' => '1', 'descriptionPlacement' => 'below'), '1' => array('id' => '2', 'isRequired' => '1', 'size' => 'medium', 'type' => 'email', 'label' => __('Email', 'cap-byline'), 'formId' => '2', 'pageNumber' => '1', 'descriptionPlacement' => 'below'), '2' => array('id' => '3', 'isRequired' => '1', 'size' => 'medium', 'type' => 'textarea', 'label' => __('Message', 'cap-byline'), 'formId' => '2', 'pageNumber' => '1', 'descriptionPlacement' => 'below'), '3' => array('allowsPrepopulate' => 1, 'id' => 4, 'size' => 'medium', 'type' => 'hidden', 'inputName' => 'author_contact_email', 'label' => __('To', 'cap-byline'), 'formId' => 2, 'pageNumber' => 1, 'descriptionPlacement' => 'below')), 'enableHoneypot' => '1', 'enableAnimation' => '1', 'id' => '2', 'notifications' => array('53a057ebea107' => array('id' => '53a057ebea107', 'to' => '{admin_email}', 'name' => __('Admin Notification', 'cap-byline'), 'event' => 'form_submission', 'toType' => 'email', 'subject' => sprintf(__('You have received a message from %s', 'cap-byline'), get_bloginfo('name')), 'message' => '{all_fields}')), 'confirmations' => array('53a057ebeadd6' => array('id' => '53a057ebeadd6', 'isDefault' => '1', 'type' => 'message', 'name' => __('Default Confirmation', 'cap-byline'), 'message' => __('Thank you for contacting me.', 'cap-byline'), 'disableAutoformat' => null, 'pageId' => null, 'url' => null, 'queryString' => null, 'conditionalLogic' => array())), 'is_active' => '1', 'date_created' => '2014-06-17 15:17:18', 'is_trash' => '0');
        $form_id = GFAPI::add_form($form);
    }
}
 /**
  * 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/preserve_role` Keep the current user role or override with the role defined in the Create feed
      * @since 1.15
      * @param[in,out] boolean $preserve_role Preserve current user role Default: true
      * @param[in] 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
      */
     $preserve_role = apply_filters('gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry);
     if ($preserve_role) {
         $config['meta']['role'] = 'gfur_preserve_role';
     }
     /**
      * Make sure the current display name is not changed with the update user method.
      * @since 1.15
      */
     $config['meta']['displayname'] = $this->match_current_display_name($entry['created_by']);
     /**
      * @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);
     $is_create_feed = $config && rgars($config, 'meta/feed_type') === 'create';
     // Only update if it's a create feed
     if (!$is_create_feed) {
         return;
     }
     // 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);
 }
function wpfg_lookup_gravityform($form_id)
{
    if (!class_exists('GFAPI')) {
        return false;
    }
    $form = GFAPI::get_form($form_id);
    if ($form['title']) {
        return $form['title'];
    }
    return false;
}
 /**
  * If a form has quiz fields, add the fields 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 quiz fields added, if exist. Unmodified if form has no quiz fields.
  */
 function add_form_fields($fields = array(), $form = array(), $include_parent_field = true)
 {
     $quiz_fields = GFAPI::get_fields_by_type($form, 'quiz');
     if (!empty($quiz_fields)) {
         $fields['gquiz_score'] = array('label' => __('Quiz Score Total', 'gravityview'), 'type' => 'quiz_score', 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'));
         $fields['gquiz_percent'] = array('label' => __('Quiz Percentage Grade', 'gravityview'), 'type' => 'quiz_percent', 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'));
         $fields['gquiz_grade'] = array('label' => __('Quiz Letter Grade', 'gravityview'), 'type' => 'quiz_grade', 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'));
         $fields['gquiz_is_pass'] = array('label' => __('Quiz Pass/Fail', 'gravityview'), 'type' => 'quiz_is_pass', 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'));
     }
     return $fields;
 }
 public function fix()
 {
     if ($this->can_fix()) {
         $forms = GFAPI::get_forms();
         foreach ($forms as $form) {
             $form['enableHoneypot'] = 1;
             GFAPI::update_form($form);
         }
     }
     return $this->run();
 }
 /**
  * Returns all the form objects
  *
  * @since  1.8.11.5
  * @access public
  * @static
  *
  * @param bool $active
  * @param bool $trash
  *
  * @return mixed The array of Forms
  */
 public static function get_forms($active = true, $trash = false)
 {
     $form_ids = GFFormsModel::get_form_ids($active, $trash);
     if (empty($form_ids)) {
         return array();
     }
     $forms = array();
     foreach ($form_ids as $form_id) {
         $forms[] = GFAPI::get_form($form_id);
     }
     return $forms;
 }
Exemple #24
0
 /**
  * Force refreshing a cache when an entry is deleted.
  *
  * The `gform_delete_lead` action is called before the lead is deleted; we fetch the entry to find out the form ID so it can be added to the blacklist.
  *
  * @since  1.5.1
  *
  * @param  int $lead_id Entry ID
  * @param  string $property_value Previous value of the lead status passed by gform_update_status hook
  * @param  string $previous_value Previous value of the lead status passed by gform_update_status hook
  *
  * @return void
  */
 public function entry_status_changed($lead_id, $property_value = '', $previous_value = '')
 {
     /** @var array $entry */
     $entry = GFAPI::get_entry($lead_id);
     if (is_wp_error($entry)) {
         /** @var WP_Error $entry */
         do_action('gravityview_log_error', __METHOD__ . ' Could not retrieve entry ' . $lead_id . ' to delete it: ' . $entry->get_error_message());
         return;
     }
     do_action('gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array('value' => $property_value, 'previous' => $previous_value));
     $this->blacklist_add($entry['form_id']);
 }
function getFormInitScripts()
{
    if (intval(get_query_var('getFormInitScripts')) != '') {
        require_once GFCommon::get_base_path() . '/form_display.php';
        $form = GFAPI::get_form(get_query_var('getFormInitScripts'));
        $field_values = array();
        // the array of parameter names and values if any fields are being populated
        GFFormDisplay::register_form_init_scripts($form, $field_values);
        $form_string = GFFormDisplay::get_form_init_scripts($form);
        echo strip_tags($form_string);
        exit;
    }
}
function gravitywp_count_func($atts, $content = null)
{
    extract(shortcode_atts(array('formid' => 'formid', 'field' => 'field'), $atts));
    $search_criteria = null;
    $sorting = null;
    $paging = array('offset' => 0, 'page_size' => 200);
    $entries = GFAPI::get_entries($formid, $search_criteria, $sorting, $paging);
    $countentries = GFAPI::count_entries($formid);
    $gwp_count = 0;
    for ($row = 0; $row < $countentries; $row++) {
        $gwp_count += $entries[$row][$field];
    }
    return $gwp_count;
}
 /**
  * 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/gravityforms/gravityforms/blob/1.8.13/forms_model.php#L587-L624
      * @see https://github.com/gravityforms/gravityforms/blob/1.8.13/includes/api.php#L495-L654
      * @see https://github.com/gravityforms/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);
     }
 }
 public static function getIdOfMusicDB_Helper()
 {
     $create_competition_form_name = 'ARIA: Create a Competition';
     $create_competition_form_id = NULL;
     $all_active_forms = GFAPI::get_forms();
     foreach ($all_active_forms as $form) {
         if ($form['title'] === $create_competition_form_name) {
             $create_competition_form_id = $form['id'];
         }
     }
     if (!isset($create_competition_form_id)) {
         $create_competition_form_id = -1;
     }
     return $create_competition_form_id;
 }
Exemple #29
0
function aria_get_music_database_form_id()
{
    $nnmta_music_database_form_name = 'NNMTA Music Database';
    $nnmta_music_database_form_id = NULL;
    $all_active_forms = GFAPI::get_forms();
    foreach ($all_active_forms as $form) {
        if ($form['title'] === $nnmta_music_database_form_name) {
            $nnmta_music_database_form_id = $form['id'];
        }
    }
    if (!isset($nnmta_music_database_form_id)) {
        wp_die('Form ' . $nnmta_music_database_form_name . ' does not exist. Please create it and try again.');
    }
    return $nnmta_music_database_form_id;
}
function getActiveMemberships($formID, $pageSize)
{
    if (class_exists("GFForms")) {
        $paging = array('offset' => 0, 'page_size' => (int) $pageSize);
        $sorting = array('key' => '19', 'direction' => 'ASC');
        $total_count = 0;
        $search_criteria = array('field_filters' => array('mode' => 'any', array('key' => 'payment_status', 'value' => 'Paid'), array('key' => '7', 'value' => 'Youth Membership (€0.00)|0'), array('key' => '7', 'value' => 'First Membership (€0.00)|0')));
        $unfilteredEntries = GFAPI::get_entries($formID, $search_criteria, $sorting, $paging, $total_count);
        $filteredEntries = array();
        foreach ($unfilteredEntries as $value) {
            array_push($filteredEntries, filterEntry($value));
        }
        return $filteredEntries;
    }
    return null;
}