Skip Navigation

[Resolved] Dispay taxonomy of user

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 4 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1454557

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.

#1456031

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