Forums

Display Custom Field

I created a custom field that is type text and is a string. I'm use people/getAll and using the custom_ID. So custom_xxxxx. I can pull the other string fields using the people/getAll, but the custom_xxx seems to be messing things up. Now thing in the foreach displays. Is it correct to displaying the custom field using custom_xxxx?

Hi Steve,


That should be correct. Text fields should be indexable using just "custom_id" from the person object. As the ID can have the - character in it though, you may need to use code like what I've shown in this thread to reference it if you're using PHP though.


Stewart

Thanks. I saw that post after I submitted my question. Here's what I'm using. It's still not working for some reason.


 

            <?php 
                     $field_id = 'custom_9c403fe8-2df8-11e6-9f8a-06023090f36d';
                     echo $result->$field_id;
            ?>

 

Hi Steve,


Can you try the method at the bottom of the page of converting $results to an array and indexing it that way?


Stewart

Here's what I'm using. It's still not working.


 

<?php
$arr = (array) $obj;
echo $arr['custom_9c403fe8-2df8-11e6-9f8a-06023090f36d'];                     
            ?>

 

Got it working. Here's the code.


 

$elvanto = new Elvanto_API($auth_details);

$allPeopleResult = $elvanto->call('people/getAll', $params=array("category_id" => "9dd29fd0-2df6-11e6-9f8a-06023090f36d","fields"=>array("custom_9c403fe8-2df8-11e6-9f8a-06023090f36d")));
$peopleList = $allPeopleResult->people->person;
?>

<?php foreach ($peopleList as $currentPerson): ?>
<div class="views-group-wrapper">
	<div class="views-group-text-wrapper">
		<div class="views-group-title-wrapper"><?php echo $currentPerson->firstname; ?> <?php echo $currentPerson->lastname; ?></div> 
		<div class="views-group-category-wrapper"><img src="<?php echo $currentPerson->picture; ?>" style="height:200px;width:auto;"></div>
		<div class="views-group-category-wrapper">
			<?php   
         $staffTitle = 'custom_9c403fe8-2df8-11e6-9f8a-06023090f36d';
         echo $currentPerson->$staffTitle;  
            ?>
		</div>
		<div class="views-group-category-wrapper">
	    <a href="mailto:<?php echo $currentPerson->email; ?>"><i class="fa fa-envelope-o"></i></a> <i class="fa fa-facebook" aria-hidden="true"></i> <i class="fa fa-twitter" aria-hidden="true"></i> <i class="fa fa-instagram" aria-hidden="true"></i>
	</div>
	<div class="views-group-link-wrapper">view</div>
</div>
<?php endforeach; ?>

 


Login or Signup to post a comment