User meta shortcodes

Use user meta as shortcode in post content without editing your theme files.

Author:Richard Vencu (profile at wordpress.org)
WordPress version required:2.7
WordPress version tested:5.4.4
Plugin version:0.5
Added to WordPress repository:10-06-2010
Last updated:03-07-2020
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:98
Rated by:7
Plugin URI:http://vencu.ro/user-meta-shortcodes/
Total downloads:12 544
Active installs:700+
plugin download
Click to start download

USAGE:

use [userinfo field=”fieldname”]some content[/userinfo] or [authorinfo field=”fieldname”]some content[/authorinfo] shortcodes in your post content to show the “fieldname” meta value from the user-meta for the current logged-in user or for the post author without editing your theme files.
use [otheruserinfo field=”fieldname” login=”userlogin” uservar=”userloginvariable”]some content[/otheruserinfo] and use login attribute if you want a fixed user login or uservar attribute if you need to dynamically supply user login via query string, where userloginvariable is the name of the query string variable such as: http://mysite.com/mypage/?userloginvariable=userlogin
You may also search for a rewrite plugin to make things nice such as http://mysite.com/mypage/userloginvariable/userlogin

EXAMPLES:

[userinfo field=”last_name”]{{empty}}[/userinfo]

returns the last name of the current logged-in user. If no user is logged in then the value is empty string

[userinfo field=”user_login” if=”admin”]You are the admin[/userinfo]

this shortcode tests the field against the value and if true it displays the included content

[userinfo field=”user_login”] is your username and you are reading a post by [authorinfo field=”user_login”]{{empty}}[/authorinfo].[/userinfo]

this will display the username followed with the processed content. Note: never use the nested shortcode same as the enclosing shortcode. This will produce unexpected results!

[userinfo nospan=”true”] should eliminate the surrounding span tag so the output can be used inside URLs or similar applications

[userinfo field=”avatar” size=”50″] will display the logged-in user’s avatar with the size of 50px. The display depends of theme’s css class ‘avatar’

List of some of the available meta field names: ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, display_name, first_name, last_name,nickname, description, user_level, admin_color (Theme of your admin page. Default is fresh.), closedpostboxes_page, nickname, primary_blog, rich_editing, source_domain

[authorinfo field=”last_name”]

returns the last name of the current post/page author.

[authorinfo field=”ID”]

returns the user ID of the current post/page author.

[authorinfo field=”avatar” size=”50″] will display the post author’s avatar with the size of 50px. The display depends of theme’s css class ‘avatar’

[authorinfo field=”posts”] will display the author’s posts link

List of some of the available meta field names: user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name,nickname, first_name, last_name, description, jabber, aim, yim, user_level, user_firstname, user_lastname, user_description, rich_editing, comment_shortcuts, admin_color,plugins_per_page, plugins_last_view, ID

[otheruserinfo field=”user_firstname” uservar=”theuserlogin”] will display the user_firstname for the user specified via query string, in the theuserlogin variable

[otheruserinfo field=”user_firstname” login=”admin”] will display the user firstname for the user specified in the login attribute

If you add custom user meta via additional plugins, then the meta should be available for the above shortcodes