Hi there,
This should be an easy one...
I have a custom taxonomy called "Sector" for users.
I am trying to display the selected sector of a user as part of my post author details.
I am using a php template for this, so we are talking api.
So far I have:
<?php echo(types_render_usermeta( 'sector' ) ); ?>
It's not working
What should I be using?
Thanks.
Hi David,
Thank you for contacting us and I'd be happy to assist.
Since custom taxonomies can only be attached with posts and not users, I'll assume you're referring to "Sector" being a user custom field.
( the "types_render_usermeta" function also is used for user custom fields and not taxonomies - https://toolset.com/documentation/customizing-sites-using-php/functions/ )
As explained in the documentation, if no user attribute is provided in the "types_render_usermeta", it gets the user field value attached to the current post's author.
If you're trying to show this on a user archive page outside any post loop, you'll first need a custom shortcode to get the ID of the user/author, whose author archive page is being viewed.
You'll find a good example of such shortcode in this reply:
https://toolset.com/forums/topic/author-page-single/#post-618800
After that, you can pass on that user's ID through the "user_id" attribute:
Example:
$user_id = do_shortcode('[get_author_id_in_archive]');
echo types_render_usermeta( "sector", array( "user_id" => $user_id ) );
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar