Search code examples
gravity-forms-plugingravityforms

Gravityview - Show payment status of another form


I currently have Gravityview view which is getting the source from form A. However, I want to show if the current user has made a payment on form B. Obviously this can be fetched from the {payment_status} merge tag of form B. But How can I pull the data of form B onto the Gravity view custom content field of form A?

I've looked at the gform_entry_id_pre_save_lead hook but I think there's a better way. Thanks for your help in advance..

    add_filter( 'gform_entry_id_pre_save_lead', 'my_update_entry_on_form_submission', 10, 2 );
    function my_update_entry_on_form_submission( $entry_id, $form ) {
    $update_entry_id = rgpost( 'my_update_entry_id' );
    return $update_entry_id ? $update_entry_id : $entry_id;
    }

Solution

  • You can either use the Gravityview Multiple Forms Add-on or you can try adding the following code to your functions.php:

    function gf_check_form($atts = array()) {
        $details = shortcode_atts( array(
            'form_id' => "",
            'user' => ""
    
        ), $atts );
        $form_id = $details['form_id'];
        $search_criteria = array(
            'status'        => 'active',
            'field_filters' => array(
                'mode' => 'all',
                array(
                    'key'   => 'created_by',
                    'operator'=> 'is',
                    'value' => $details['user']
                )
            )
        );
        $entries = GFAPI::get_entries( $form_id, $search_criteria);
        foreach($entries as $entry){
           $paid .= 'Paid on '.date("F d, Y", strtotime($entry['date_created'])).'<br><br>';
        }
        return $paid;
    }
    add_shortcode( 'check_form', 'gf_check_form' );
    

    You can then add the following shortcode to your Gravityview in a custom content field:

    [check_form form_id="Add the form ID of form B here" user="{created_by:ID}"]