Hello
I have a taxonomy called “subject” that is part of a CTP called “topics”.
I have a custom field group with a location rule set for all users.
I have a custom field called “specialist_topic” that is set to the Taxonomy Field Type. Within this I select “subject” from the Taxonomy drop-down, “Select” from the Field Type drop-down, and Term Object from the Return Value field.
When editing a User Profile, I select a taxonomy term from the custom field and save it.
In my author.php file, I’d like to display the taxonomy term value. I am doing this like so:
// Get author ID
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
// Var for custom field
$specialtopic = get_field('specialist_topic', 'user_' . $curauth->ID);
// Output the taxonomy term
echo $specialtopic;
I get this error:
Catchable Fatal Error: Object Of Class StdClass Could Not Be Converted To String In
Var Dump shows (“Food” is the correct tax term)
Object(StdClass)#257 (9) { ["Term_id"]=> String(3) "122" ["Name"]=> String(4) "Food" ["Slug"]=> String(4) "Food" ["Term_group"]=> String(1) "0" ["Term_taxonomy_id"]=> String(3) "128" ["Taxonomy"]=> String(7) "Subject" ["Description"]=> String(20) "Top 10 Food Websites" ["Parent"]=> String(1) "0" ["Count"]=> String(1) "3" }
Alternatively, when I change the Return Value of ID I can happily output the ID # without the error.
Any ideas where I’m going wrong?
Thanks
Dave