I am trying to format the HTML layout of the admin email that is sent after a user submits the form. I'm using the my_forms_action function in my-functions.php.
Basically, if you submit with the code below to a valid email address it will return the form's array in the email, like this:
Array
(
[$$$1] => Fieldset1
[Fieldset1] => Patient Information
[$$$2] => Your Name
[Your Name] => sadlfj
[$$$3] => Address
[Address] => lkjadsf
)
This works fine, but I'm not sure how to loop through this array to add HTML around it.
I added some comments to the code snippet below for my_forms_action so you can see what I am trying to do.
Thanks in advance for any help!
function my_cforms_action($cformsdata) {
### Extract Data
### Note: $formID = '' (empty) for the first form!
$formID = $cformsdata['id'];
$form = $cformsdata['data'];
if ( $formID == '3' ) {
### right here I need to loop through the array to
### add formatting like table, tr, td, etc around each field.
### Also, not sure how to tell if field is a fieldset so I can apply different styling?
### $form['Your Name'] = 'Mr./Mrs. '.$form['Your Name'];
}
### Need to replace print_r($form,1) with some variable from loop above
@mail('myemail', 'cforms my_action test', print_r($form,1), 'From: your@blog.com');
}