Skip to content

Instantly share code, notes, and snippets.

@webaware
Created September 30, 2012 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webaware/3808642 to your computer and use it in GitHub Desktop.
Save webaware/3808642 to your computer and use it in GitHub Desktop.
filter the eWAY invoice description for a Gravity Form post
<?php
/**
* filter the eWAY invoice description for a Gravity Form post
* @param string $desc the description before filtering
* @param array $form the Gravity Form object
* @return string
*/
function my_gfeway_invoice_desc($desc, $form) {
// set by form ID
switch ($form['id']) {
case 1:
$desc = 'Donate form';
break;
case 6:
$desc = 'Recurring payment form';
break;
}
// set by hidden field
foreach($form['fields'] as $field) {
if (RGFormsModel::get_input_type($field) == 'hidden' && $field['label'] == 'Invoice Description') {
$desc = rgpost('input_' . $field['id']);
break;
}
}
return $desc;
}
add_filter('gfeway_invoice_desc', 'my_gfeway_invoice_desc', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment