Created
September 30, 2012 22:41
-
-
Save webaware/3808642 to your computer and use it in GitHub Desktop.
filter the eWAY invoice description for a Gravity Form post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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