How to get User meta fields and show on site

Many plugins allow you to extend custom meta fields for Users. But How can you show these values on site.

Well, it’s depending on place where you want to show. Mostly, you can need two global places

Post pages, post loops

This place is useful when you want to show some details of post’s author. It will work on inner post pages. Shortcode to get custom value is next

[wpsm_custom_meta field="META-KEY-NAME" label="My label:" show_empty=1 posttext="after value text" icon="" list="" type="author"] 

Key point in this code is type=author. This will tell wordpress to get author of post and shows him user’s meta value (place key of meta value which you want to get in “field”)

You can find description of all parameters in article about meta getter

Store pages

Use this place if you want to get value of Vendor user on his vendor store page

[wpsm_custom_meta field="META-KEY-NAME" label="My label:" show_empty=1 posttext="after value text" icon="" list="" type="vendor"] 

So, code is the same but you must use type=vendor. Place this shortcode in HTML widget in Apearance – widgets – Vendor store widget area

Buddypress Profile

If you use Profile builder of Buddypress instead Custom user meta, you can use special shortcode to get values from them and use it on site

Read About Buddypress User shortcodes of theme

Conditional shortcodes

If you want to show values not for all users or inside special categories, you may need conditional shortcodes

Php functions

If you want to add customization, you can use direct function instead shortcode. So, example, of using function for code above

<?php echo wpsm_custom_meta(array('field'=>'META_KEY_NAME', 'type'=>'vendor'));?>