Passing data from after_submission action to the confirmation filter in gravity forms?

I am creating a post within gform_after_submission action, which sets a post ID variable when the post is successfully created. https://docs.gravityforms.com/gform_after_submission/ add_action('gform_after_submission_1', [ $this, 'create_order' ], 10, 2 ); public function create_order( $entry, $form ) { // get the current cart data array $data = self::data(); // user id $user_id = get_current_user_id(); // create an order array $order = [ 'post_author' => $user_id, 'post_content' => json_encode($data,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES), 'post_type' => 'purchase-order', 'post_status' => 'publish' ]; // create order post using an array …
Category: Web

Foreach loop through Gravity Forms entries

So, I'm trying to iterate through a foreach loop of all the entries to a gravity forms form. I have it sort of working in a template, but I need to put it in a class (creating a calendar and need to pull in entry information) and now it is just iterating over the last entry a bunch of times. Not sure where I went wrong: $form_id = 9; //Enter the form ID here. The PTO form ID is 9; …
Category: Web

Keyword checking in Gravity Forms

In Gravity Forms I'd like to include a small keyword checker that is checking the user's message for "spammy" words and stops sending the entry to the admin. For this a hidden field changes it's value. I have this code included in my functions.php so far function strpos_arr($haystack, $needle) { if(!is_array($needle)) $needle = array($needle); foreach($needle as $what) { if(($pos = stripos($haystack, $what))!==false) return $pos; } return false; } /* * Our bad words validation function */ add_action('gform_pre_submission_1', 'keywords_check'); function keywords_check($validation_result){ …
Category: Web

Undefined fieldId in gform.addFilter for limiting dates in datepicker - Gravity Forms

I've added support for datepicker on date fields in entry detail edit admin page of Gravity Forms. I did this by simply enqueuing the gform_datepicker_init script in admin_enqueue_scripts hook. This works perfectly as datepicker is displayed for date fields which was not available by default in entry detail edit page. My form has additional requirements and I want to limit the dates in a datepicker field. So, for that I want to take advantage of a JS filter gform_datepicker_options_pre_init provided …
Category: Web

Update media library image shown in "attachment details" when using wp_insert_attachment to add item to the media library

I'm using the function wp_insert_attachment() to run on a form submission from GravityForms, take a file uploaded in the form, and add it to the WordPress Media Library. Code in functions.php below, also in Github: function form_to_media_library($entry){ // from https://developer.wordpress.org/reference/functions/wp_insert_attachment/#div-comment-948 // set filename $upload_path = GFFormsModel::get_upload_path( $entry[ 'form_id' ] ); $upload_url = GFFormsModel::get_upload_url( $entry[ 'form_id' ] ); $filename_verbose = str_replace( $upload_url, $upload_path, $entry[ '1' ] ); $filename = trim($filename_verbose, ' "[]\ '); // check the type of file. We'll use …
Category: Web

How to download CSV from sub directory in uploads folder

hello guys i donot have experience working with the csv. I have a very big form i wanted to make a custom csv export for this form and a new csv is generated every time the form is submited. i am using gravity form and gravity form gform_post_submissiom hook to capture the entry. Everything is working fine until this point. I have created a sub dir in uploads folder. Csv for every entry is being created in this folder. I …
Category: Web

Gravity Forms & Flow - dynamically create list row and populate row fields

:) I have a big gravity form with conditional fields. If a field is relevant - only if relevant - I would like the data from that field to be passed to a LIST field. I would like it to create a new row (not replace the data already there). And I would like that row to then be populated with dynamic data. I have got a snippets plugin and I also have gravity flow and form connector. Any thoughts?
Category: Web

gravityforms chart

Is there any easy way to implement some charts for the gravityforms submitted data (and being able to filter it) without having to spend 500$ on a premium plugin/addon? I would like to create a page showing the current logged user his submissions data displayed with charts. Any suggestion on how to achieve this? Thanks
Category: Web

Manipulate the files uploaded via Gravity Forms before they are stored

I would like to make changes to files (for e.g. compress them into a zip) uploaded via Gravity Forms File upload field before they are uploaded to the webserver. Do you know of any hook or workaround to modify the (temporary) file before it is sent to and stored on the webserver? (I have found a solution to do it after the files are uploaded, but that is not what I am looking for.)
Category: Web

Load gravity form via ajax using do_shortcode

I am reloading my form using ajax upon confirmation. This is working perfectly and I am parsing my form_id to the action function fine... // code to trigger stuff when forms have submitted $(document).on('gform_confirmation_loaded', function(event, form_id){ // run code for white label site editor form if(form_id == 12) { // reload our form $.ajax({ cache: false, timeout: 30000, url: admin_ajax_url, type: 'GET', data: { action : 'gf_reload_editor_form', post_id : post_id, form_id : form_id, isAjax : true }, success: function (data) …
Category: Web

gravityform - retrieve multiple check answers "keys" instead of "values"

I need to implement a custom math sum relative to the answers of a multiple checkbox question. Let's suppose I have a question like this: Question: first choice second choice third choice If I "show values", by default, the value will be equal to the key. so: first choice = "first choice" second choice = "second choice" third choice = "third choice" Let's suppose I give these 3 answers numeric values, for example: first choice = 3 second choice = …
Category: Web

Using Gravity Forms to upload media into library, then attach to post

I have a simple site with two Gravity Forms, both of which allow users to upload media. I'm looking for some simple code that: (a) inserts all uploaded media into the Media Library and not the default Gravity Forms folder (b) attaches media to pages. Form 1 attach to page 1, form 2 to page 2. I've found a few similar posts, but nothing simple that does exactly what I need. I guess I'd use something like add_action( 'gform_after_submission_1', 'after_submission', …
Category: Web

Gravity forms - get shortcode attribute from post content

I have some posts and some of them contain [gravityform] shortcode with different attribute values. Say, a post Hello World contains a shortcode [gravityform id="1" title="false" description="false"] Another post Hello Moon contains shortcode [gravityform description="true" id="23" title="true"] How can I get the value of id attribute of that shortcode programmatically?
Category: Web

using shortcodes inside gravity forms

I'm struggling to use a custom short code (added by some plugin named short code plus) inside a hidden input in gravityforms the short code is [user_firstname] which as it's obvious it shows the users first name no matter how i tried, it wont return users first name to my form entries if i use the short code inside a html type input it will be shown in front end of website and it works correctly but it wont be …
Category: Web

Gravity form Load By Ajax Cannot Submit - Error 400

I have an issue with Gravity forms. I successfully loaded Gravity Forms via ajax, but I got an error of 400 when I submit the form. I tried all solutions but still can't submit the forms. here is my ajax code var data = { action': 'step_3_ajax_content', } $.ajax({ type: "POST", url: ajax.url, data: data, beforeSend: function() { $(".loading").show(); }, success: function(response) { $('.wizards-content-ajax').html(response); $(".loading").hide(); } }); to show forms I use shortcode <?php echo do_shortcode( '[gravityform id="1" title="false" description="false" …
Category: Web

Gravity Forms Multiple Dates Filled by 1st Date

I'm trying to figure out if there is a way to have multiple dates on a form be filled by the first date. I have 14 dates on the form. I want the user to pick the date on the first date and have the remaining dates autofill but cascading so it'll be two weeks of dates. I have no idea if this is possible.
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.