bux23
7/12/2016 - 2:53 PM

WP Gravity Form external submission

WP Gravity Form external submission

add_action( 'gform_after_submission_2', 'post_to_prev_mark', 10, 2 );
function post_to_prev_mark( $entry, $form ) {
    
    $post_url = 'phpFileUrl';
    $body = array(
        'mq' => rgar( $entry, '1' ), 
        'bagni' => rgar( $entry, '14' ), 
        'cso' => rgar( $entry, '3' ),
        'cond' => rgar( $entry, '4' ),
        'elet' => rgar( $entry, '5.1' ),
        'idra' => rgar( $entry, '5.2' ),
        'gas' => rgar( $entry, '5.3' ),
        'term' => rgar( $entry, '5.4' ),
        'nome' => rgar( $entry, '10' ),
        'usr_em' => rgar( $entry, '12' ),
        'tel' => rgar( $entry, '20' ),
        'citta' => rgar( $entry, '13' ),
        'provincia' => rgar( $entry, '19' ),
        'page' => rgar( $entry, '16' ),
        'view_num' => $_SESSION['view_num'],
        'first_view_ref' => $_SESSION['first_view_ref'],
        'first_view' => $_SESSION['first_view'],
        'first_camp_name' => $_SESSION['f_camp_name'],
        'first_camp_source' => $_SESSION['f_camp_source'],
        'first_camp_medium' => $_SESSION['f_camp_medium'],
        'first_camp_term' => $_SESSION['f_camp_term'],
        'first_camp_content' => $_SESSION['f_camp_content'],
        'first_camp_ref' => $_SESSION['f_camp_ref'],
        'camp_name' => $_SESSION['camp_name'],
        'camp_source' => $_SESSION['camp_source'],
        'camp_medium' => $_SESSION['camp_medium'],
        'camp_term' => $_SESSION['camp_term'],
        'camp_content' => $_SESSION['camp_content'],
        'camp_ref' => $_SESSION['camp_ref'],
        'refurl' => $_SESSION['refer_url'],
        );
    GFCommon::log_debug( 'gform_after_submission: body => ' . print_r( $body, true ) );

    $request = new WP_Http();
    $response = $request->post( $post_url, array( 'body' => $body ) );
    GFCommon::log_debug( 'gform_after_submission: response => ' . print_r( $response, true ) );
}