Skip to content

Instantly share code, notes, and snippets.

@chrisjimallen
Created October 16, 2017 09:06
Show Gist options
  • Save chrisjimallen/cc6e676226d944710845f4110a3cffca to your computer and use it in GitHub Desktop.
Save chrisjimallen/cc6e676226d944710845f4110a3cffca to your computer and use it in GitHub Desktop.
erc.php
<?php
function theme_enqueue_styles() {
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'avada-stylesheet' ) );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function avada_lang_setup() {
$lang = get_stylesheet_directory() . '/languages';
load_child_theme_textdomain( 'Avada', $lang );
}
add_action( 'after_setup_theme', 'avada_lang_setup' );
add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
//add_action("gform_after_submission", "after_submission", 10, 2);
function after_submission($entry, $form){
$message = print_r($entry, true);
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('[email protected]', 'Getting the Gravity Form Field IDs', $message);
}
add_action( 'gform_after_submission_1', 'callback_post_to_third_party', 10, 2 );
function callback_post_to_third_party( $entry, $form ) {
$formType = rgar( $entry, '7' );
if ($formType == 'Full Enquiry') {
$post_url = 'https://secure.digi-masters.net/ERC/public/enquiry/external-submit.php';
$body = array(
'src' => 'ERCCOUK',
's2_fname' => rgar( $entry, '6.3' ),
's2_sname' => rgar( $entry, '6.6' ),
's2_tel' => rgar( $entry, '2' ),
's2_email' => rgar( $entry, '3' ),
's2_bestCall' => rgar( $entry, '9' ),
's3_propVal' => rgar( $entry, '8' )
);
}
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
add_action( 'gform_after_submission_3', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {
$formType = rgar( $entry, '7' );
if ($formType == 'Full Enquiry') {
$post_url = 'https://secure.digi-masters.net/ERC/public/enquiry/external-submit.php';
$body = array(
'src' => 'ERCCOUK',
's2_title1' => rgar( $entry, '1' ),
's2_fname' => rgar( $entry, '2.3' ),
's2_sname' => rgar( $entry, '2.6' ),
's2_add' => rgar( $entry, '3.1' ).', '.rgar( $entry, '3.2' ).', '.rgar( $entry, '3.3' ).', '.rgar( $entry, '3.4' ),
's2_pcode' => rgar( $entry, '3.5' ),
's2_tel' => rgar( $entry, '4' ),
's2_mtel' => rgar( $entry, '5' ),
's2_email' => rgar( $entry, '6' ),
's2_bestCall' => rgar( $entry, '9' ),
's3_jown' => rgar( $entry, '10' ),
's3_propType' => rgar( $entry, '13' ),
's3_hold' => rgar( $entry, '14' ),
's3_propVal' => rgar( $entry, '15' ),
's3_osMort' => rgar( $entry, '16' ),
's4_minAmt' => rgar( $entry, '17' ),
's4_scheme' => rgar( $entry, '18' ),
'comments' => rgar( $entry, '19' )
);
$ownership = rgar( $entry, '10' );
if ($ownership == 'single') {
$dob1 = rgexplode('-', rgar( $entry, '11' ), 3);
$body['s2_DOBDay'] = $dob1[2];
$body['s2_DOBMonth'] = $dob1[1];
$body['s2_DOBYear'] = $dob1[0];
}
else {
$dob1 = rgexplode('-', rgar( $entry, '11' ), 3);
$body['s2_DOBDay'] = $dob1[2];
$body['s2_DOBMonth'] = $dob1[1];
$body['s2_DOBYear'] = $dob1[0];
$dob2 = rgexplode('-', rgar( $entry, '12' ), 3);
$body['s2_DOB2Day'] = $dob2[2];
$body['s2_DOB2Month'] = $dob2[1];
$body['s2_DOB2Year'] = $dob2[0];
$body['s2_title2'] = rgar( $entry, '32' );
$body['s2_fname2'] = rgar( $entry, '33.3' );
$body['s2_sname2'] = rgar( $entry, '33.6' );
}
}
else {
$post_url = 'https://secure.digi-masters.net/ERC/public/contact/brochure-request.php';
$body = array(
'src' => 'ercv2',
'ap' => '1',
's2_title1' => rgar( $entry, '1' ),
's2_fname' => rgar( $entry, '2.3' ),
's2_sname' => rgar( $entry, '2.6' ),
's2_add' => rgar( $entry, '3.1' ).', '.rgar( $entry, '3.2' ).', '.rgar( $entry, '3.3' ).', '.rgar( $entry, '3.4' ),
's2_pcode' => rgar( $entry, '3.5' ),
's2_tel' => rgar( $entry, '4' ),
's2_mtel' => rgar( $entry, '5' ),
's2_email' => rgar( $entry, '6' ),
's2_method' => rgar( $entry, '8' ),
'comments' => rgar( $entry, '19' )
);
}
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
//error_log( 'gform_after_submission: response => ' . print_r( $response, true ) );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment