Custom Fields in Results API

Follow the below to pull custom fields into the Results API.

Adding custom fields in results API

Locate the table that displays the results for each visitor.  It will look similar to the table below:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
 <th width="200px">Name</th> 
 <th width="150px">Phone</th>
 <th width="300px">Email</th>
 <th>Visit Date/Time</th>
 </tr>
 <?php foreach($page as $result) { ?>
 <tr>
 <td><?php echo $result->contact_firstName.' '.$result->contact_lastName; ?>&nbsp;</td>
 <td><?php echo $result->contact_phone; ?>&nbsp;</td>
 <td><a href="mailto:<?php echo $result->contact_email; ?>"><?php echo $result->contact_email; ?></a>&nbsp;</td>
 <td><?php echo date('M j Y - g:ia',strtotime($result->result_timestamp)); ?>&nbsp;</td>
 </tr>
 <?php } ?>
 </table>
	

Then add a new column to the table to pull in the custom field data:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
 <th width="200px">Name</th> 
 <th width="150px">Phone</th>
 <th width="300px">Email</th>
 <th width="300px">Custom Field</th>
 <th>Visit Date/Time</th>
 </tr>
 <?php foreach($page as $result) { ?>
 <tr>
 <td><?php echo $result->contact_firstName.' '.$result->contact_lastName; ?>&nbsp;</td>
 <td><?php echo $result->contact_phone; ?>&nbsp;</td>
 <td><a href="mailto:<?php echo $result->contact_email; ?>"><?php echo $result->contact_email; ?></a>&nbsp;</td>
 <td><?php echo $result->contacts_cf_1; ?>&nbsp;</td>
 <td><?php echo date('M j Y - g:ia',strtotime($result->result_timestamp)); ?>&nbsp;</td>
 </tr>
 <?php } ?>
 </table>
	

As seen above the variable used to pull in the custom field is as follows:

$result->contacts_cf_1
	

This will pull in the first custom field as defined in the contact's profile page.