• 1.
        /**
  • 2.
         * Stash the "final" version of the files after other add-ons have had a chance to interact with them.
  • 3.
         *
  • 4.
         * @param $entry
  • 5.
         * @param $form
  • 6.
         */
  • 7.
        function stash_uploaded_files( $entry, $form ) {
  • 8.
            
  • 9.
            $fields_to_treat = $this->_args['file_nb'];
  • 10.
            // disable notifications until we reach the last field to treat
  • 11.
            add_filter( 'gform_disable_notification', 'disable_notification_by_field', 10, 4 );
  • 12.
            function disable_notification_by_field( $is_disabled, $form, $entry, $fields_to_treat ) {
  • 13.
                if($fields_to_treat > 0){
  • 14.
                    return true;
  • 15.
                }
  • 16.
                return $is_disabled;
  • 17.
            }
  • 18.
            
  • 19.
            foreach ( $form['fields'] as &$field ) {
  • 20.
                
  • 21.
                if ( ! $this->is_applicable_field( $field ) ) {
  • 22.
                    continue;
  • 23.
                } else {
  • 24.
                    $fields_to_treat -=1;
  • 25.
                    apply_filters('gform_disable_notification', $is_disabled, $form, $entry, $fields_to_treat);
  • 26.
                }
  • 27.
                $uploaded_files = rgar( $entry, $field->id );
  • 28.
                gform_update_meta( $entry['id'], 'gprf_stashed_files', $uploaded_files );
  • 29.
                
  • 30.
            }
  • 31.
            
  • 32.
            return $entry;
  • 33.
        }
/** * Stash the "final" version of the files after other add-ons have had a chance to interact with them. * * @param $entry * @param $form */ function stash_uploaded_files( $entry, $form ) { $fields_to_treat = $this->_args['file_nb']; // disable notifications until we reach the last field to treat add_filter( 'gform_disable_notification', 'disable_notification_by_field', 10, 4 ); function disable_notification_by_field( $is_disabled, $form, $entry, $fields_to_treat ) { if($fields_to_treat > 0){ return true; } return $is_disabled; } foreach ( $form['fields'] as &$field ) { if ( ! $this->is_applicable_field( $field ) ) { continue; } else { $fields_to_treat -=1; apply_filters('gform_disable_notification', $is_disabled, $form, $entry, $fields_to_treat); } $uploaded_files = rgar( $entry, $field->id ); gform_update_meta( $entry['id'], 'gprf_stashed_files', $uploaded_files ); } return $entry; }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter