Title: Get User Custom Field Values
Author: Scott Reilly
Published: <strong>August 8, 2011</strong>
Last modified: November 21, 2021

---

Search plugins

![](https://ps.w.org/get-user-custom-field-values/assets/banner-772x250.png?rev=
840639)

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://ps.w.org/get-user-custom-field-values/assets/icon-128x128.png?rev=1105754)

# Get User Custom Field Values

 By [Scott Reilly](https://profiles.wordpress.org/coffee2code/)

[Download](https://downloads.wordpress.org/plugin/get-user-custom-field-values.3.3.zip)

 * [Details](https://frp.wordpress.org/plugins/get-user-custom-field-values/#description)
 * [Reviews](https://frp.wordpress.org/plugins/get-user-custom-field-values/#reviews)
 *  [Installation](https://frp.wordpress.org/plugins/get-user-custom-field-values/#installation)
 * [Development](https://frp.wordpress.org/plugins/get-user-custom-field-values/#developers)

 [Support](https://wordpress.org/support/plugin/get-user-custom-field-values/)

## Description

This plugin provides a powerful widget, shortcode (with shortcode builder tool),
and template tags for easily retrieving and displaying custom field values for the
currently logged in user or any specified user.

This plugin provides functionality similar to the [Get Custom Field Values](https://wordpress.org/plugins/get-custom-field-values/)
plugin, but for user custom fields (which WordPress manages in a separate database
table).

This plugin does NOT help you in setting user custom field values, nor does it provide
an interface to list or otherwise manage user custom fields.

The list of useful user custom field values that are provided by default in WordPress
are:

 * first_name
 * last_name
 * nickname
 * Dèscripcion
 * aim
 * yim
 * jabber

It is up to other plugins or custom code to add additional user custom fields that
you may then be able to retrieve with this plugin.

Links: [Plugin Homepage](https://coffee2code.com/wp-plugins/get-user-custom-field-values/)
| [Plugin Directory Page](https://wordpress.org/plugins/get-user-custom-field-values/)
| [GitHub](https://github.com/coffee2code/get-custom-field-values/) | [Author Homepage](https://coffee2code.com)

### Developer Documentation

Developer documentation can be found in [DEVELOPER-DOCS.md](https://github.com/coffee2code/get-custom-field-values/blob/master/DEVELOPER-DOCS.md).
That documentation covers the numerous template tags, hooks, and shortcode provided
by the plugin.

As an overview, these are the template tags provided the plugin:

 * `c2c_get_current_user_custom()` : Template tag to get custom fields for the currently
   logged in user.
 * `c2c_get_author_custom()` : Template tag to get custom fields for the current
   author (when on the permalink page for a post, page, or in a loop).
 * `c2c_get_user_custom()` : Template tag to get custom fields for a specified user.

These are the hooks provided by the plugin:

 * `c2c_get_current_user_custom` : An alternative approach to safely invoke `c2c_get_current_user_custom()`
   in such a way that if the plugin were deactivated or deleted, then your calls
   to the function won’t cause errors in your site.
 * `c2c_get_author_custom` : An alternative approach to safely invoke `c2c_get_author_custom()`
   in such a way that if the plugin were deactivated or deleted, then your calls
   to the function won’t cause errors in your site.
 * `c2c_get_user_custom` : An alternative approach to safely invoke `c2c_get_user_custom()`
   in such a way that if the plugin were deactivated or deleted, then your calls
   to the function won’t cause errors in your site.
 * `c2c_get_user_custom_field_values_shortcode` : Filter to customize the name of
   the plugin’s shortcode.
 * `c2c_get_user_custom-user_field_proxy` : Filter to prevent proxying to user object
   fields if no value for the custom field was found for the user.
 * `get_user_custom_field_values/can_author_use_shortcodes` : Filter to customize
   if post author can make use of the ‘user_custom_field’ shortcode.
 * `get_user_custom_field_values/show_metabox` : Filter to customize if the shortcode
   builder metabox is shown.

The shortcode provided is `[user_custom_field]`, which has a number of attributes
to customize its behavior and output.

## Screenshots

 * [[
 * Screenshot of the ‘Get User Custom’ widget.
 * [[
 * Screenshot of the ‘Get User Custom’ shortcode builder (not available in the block
   editor, aka Gutenberg).

## Installation

 1. Install via the built-in WordPress plugin installer. Or install the plugin code
    inside the plugins directory for your site (typically `/wp-content/plugins/`).
 2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
 3. Optional: Add filters for ‘the_user_meta’ to filter user custom field data (see
    the end of the file for commented out samples you may wish to include). And/or 
    add per-meta filters by hooking ‘the_user_meta_$field’
 4. Give a user a custom field with a value, or have user custom fields already defined.(
    This generally entails use of plugin(s) that utilize the user custom fields feature
    built into WordPress. By default, in a practical sense WordPress only sets the ‘
    first_name’, ‘last_name’, and ‘nickname’ user custom fields, so you could try using
    one of them, even if just for testing even though WordPress provides functions 
    to get those particular fields.)
 5. Optional: Use the provided ‘Get User Custom’ widget -or-
     Use the available shortcode
    in a post or page -or- Use the function `c2c_get_current_user_custom()` if you 
    wish to access user custom fields for the currently logged in user. Use the function`
    c2c_get_user_custom()` to access user custom fields for a specified user. Use the
    function c2c_get_author_custom() to access custom fields for the current author(
    when on the permalink page for a post, page, or in a loop). Prepend either of the
    three mentioned functions with ‘echo’ to display the contents of the custom field;
    or use the return value as an argument to another function.

## FAQ

### How do I assign users custom fields so that I can retrieve them using this plugin?

The user profile page within WordPress provides inputs for a handful of user custom
fields (first_name, last_name, aim, yim, jabber, description, etc). However, you’re
probably more interested in creating your own user custom fields. In that case, 
you’ll have to use another plugin to store custom fields for users, or directly 
use WordPress functions manually.

### I don’t plan on using the shortcode builder when writing or editing a post or page, so how do I get rid of it?

If you use the block editor (aka Gutenberg, which is the default editing experience
as of WordPress 5.0), then the shortcode builder is not available yet so this situation
would be moot for you.

For the classic editor, when on the Write or Edit admin pages for a page or post,
find the “Screen Options” link near the upper right-hand corner. Clicking it slides
down a panel of options. In the “Show on screen” section, uncheck the checkbox labeled“
Get User Custom Field Values – Shortcode”. This must be done separately for posts
and for pages if you want the shortcode builder disabled for both sections.

### I don’t see the shortcode builder; where is it?

If you use the block editor (aka Gutenberg, which is the default editing experience
as of WordPress 5.0), then the shortcode builder is not available yet.

If you aren’t able to include scripts in your posts (i.e. you don’t have the ‘unfiltered_html’
capability), then the shortcode builder is not available to you. Only those with
the editor or administrator role (except on Multisite) or the super administrator
role can make use of this plugin’s shortcode.

For the classic editor, the shortcode builder/wizard is available in the admin when
writing or editing a page or post. On the edit/create page, it’ll be a sidebar widget(
in this context, also known as a metabox) labeled “Get User Custom Field Values –
Shortcode”. If you don’t see it there (which may be the case since it is hidden 
by default), find the “Screen Options” link near the upper righthand corner of the
page. Clicking it slides down a panel of options. In the “Show on screen” section,
check the checkbox labeled “Get User Custom Field Values – Shortcode”. This must
be done separately for posts and for pages if you want the shortcode builder enabled
for both sections.

### Can I move the shortcode builder box because it is way down at the bottom of the right sidebar when I create/edit posts?

Yes, any of the boxes on the page when creating/editing posts can be rearranged 
by dragging and dropping the box name. At the very top of the shortcode builder 
box the cursor will turn into a four-way array indicating you can click to drag 
that box. You can move it under the post content box, or higher up on the right 
side.

### Why didn’t the shortcode get inserted into the editor after I clicked the “Send shortcode to editor” button?

Sometimes you have to ensure the text editor has focus. Click within the text editor
and make sure the cursor is positioned at the location you want the shortcode to
be inserted. Then click the button and the shortcode should get inserted there.

### Is this plugin compatible with the new block editor (aka Gutenberg)?

Yes, except that the shortcode builder (a custom tool to facilitate making use of
the plugin’s shortcode when creating a post) has not been ported over yet. The template
tags, widget, and shortcode itself all function properly.

### Does this plugin include unit tests?

Yes.

## Reviews

![](https://secure.gravatar.com/avatar/55d537023e29ec5d7861c72b77e7cd59f5b8b44d8fd2e27ab10f3bf38d231213?
s=60&d=retro&r=g)

### 󠀁[plugin menu where](https://wordpress.org/support/topic/plugin-menu-where/)󠁿

 [adamids](https://profiles.wordpress.org/adamids/) March 17, 2020 1 reply

plugin menu where

![](https://secure.gravatar.com/avatar/64321d26b804b657641a841621ca3439f0002f8c3dbdef17b518ab45c6b013da?
s=60&d=retro&r=g)

### 󠀁[Great plugin](https://wordpress.org/support/topic/great-plugin-10221/)󠁿

 [Akawey](https://profiles.wordpress.org/akawey/) September 3, 2016

This plugin works and is simply great.

 [ Read all 3 reviews ](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/)

## Contributors & Developers

“Get User Custom Field Values” is open source software. The following people have
contributed to this plugin.

Contributors

 *   [ Scott Reilly ](https://profiles.wordpress.org/coffee2code/)

[Translate “Get User Custom Field Values” into your language.](https://translate.wordpress.org/projects/wp-plugins/get-user-custom-field-values)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/get-user-custom-field-values/),
check out the [SVN repository](https://plugins.svn.wordpress.org/get-user-custom-field-values/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/get-user-custom-field-values/)
by [RSS](https://plugins.trac.wordpress.org/log/get-user-custom-field-values/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 3.3 (2021-11-09)

Highlights:

This recommended release prevents users who can’t post unfiltered HTML from using
the shortcode in posts (security hardening), adds some new filters, adds DEVELOPER-
DOCS.md, notes compatibility through WP 5.8+, and reorganizes and improves unit 
tests.

Details:

 * Change: Prevent users who cannot post unfiltered HTML from using the shortcode
   in posts. Props Francesco Carlucci and Erwan.
    - Hardens security to prevent potentail information disclosure or XSS by authors
      with limited privileges
    - New: Add shortcode class function `can_author_use_shortcodes()`
    - New: Add filter `'get_user_custom_field_values/can_author_use_shortcodes'`
    - Change: Prevent shortcodes created by users who cannot publish unfiltered 
      HTML from being evaulated
    - Change: Prevent display of shortcode builder metabox to users who cannot publish
      posts
 * New: Add filter `'get_user_custom_field_values/show_metabox'` to customize if
   shortcode builder metabox is shown
 * New: Add DEVELOPER-DOCS.md and move template tag and shortcode documentation 
   into it
 * Change: Note compatibility through WP 5.8+
 * Change: Update copyright date (2021)
 * Change: Update shortcode builder widget to 008
 * Change: Tweak installation instructions
 * Unit tests:
    - Change: Split shortcode-related tests out into their own file
    - Change: Split widget-related tests out into their own file
    - New: Add unit tests for `show_metabox()`
    - New: Add helper function `create_post()`
    - Change: Restructure unit test file structure
       * Change: Move `phpunit/bin/` to `tests/bin/`
       * Change: Move `phpunit/bootstrap.php` into `tests/phpunit/`
       * Change: Move tests from `phpunit/tests/` to `tests/phpunit/tests/`
       * Change: In bootstrap, store path to plugin file constant so its value can
         be used within that file and in test file
       * Change: In bootstrap, check for test installation in more places and exit
         with error message if not found
       * Change: Remove ‘test-‘ prefix from unit test files
 * New: Add a few more possible TODO items

#### 3.2.2 (2020-09-18)

 * Change: Restructure unit test file structure
    - New: Create new subdirectory `phpunit/` to house all files related to unit
      testing
    - Change: Move `bin/` to `phpunit/bin/`
    - Change: Move `tests/bootstrap.php` to `phpunit/`
    - Change: Move `tests/` to `phpunit/tests/`
    - Change: Rename `phpunit.xml` to `phpunit.xml.dist` per best practices
 * Change: Note compatibility through WP 5.5+

#### 3.2.1 (2020-06-07)

 * Change: Update shortcode builder widget to 007:
    - New: Store object instantiated during `register()`
    - Change: Cast return value of `c2c_get_user_custom_field_values_post_types`
      filter as an array
    - Change: Sanitize string used in markup attributes (hardening)
 * New: Add TODO.md and move existing TODO list from top of main plugin file into
   it (and added to it)
 * Change: Note compatibility through WP 5.4+
 * Change: Update links to coffee2code.com to be HTTPS
 * Change: Update link to Get Custom Field Values plugin to point to wordpress.org
   instead of my site
 * Change: Unit tests: Use HTTPS for link to WP SVN repository in bin script for
   configuring unit tests (and delete commented-out code)

_Full changelog is available in [CHANGELOG.md](https://github.com/coffee2code/get-user-custom-field-values/blob/master/CHANGELOG.md)._

## Meta

 *  Version **3.3**
 *  Last updated **4 years ago**
 *  Active installations **90+**
 *  WordPress version ** 4.6 or higher **
 *  Tested up to **5.8.13**
 *  Language
 * [English (US)](https://wordpress.org/plugins/get-user-custom-field-values/)
 * Tags
 * [custom field](https://frp.wordpress.org/plugins/tags/custom-field/)[shortcode](https://frp.wordpress.org/plugins/tags/shortcode/)
   [user](https://frp.wordpress.org/plugins/tags/user/)[user meta](https://frp.wordpress.org/plugins/tags/user-meta/)
   [widget](https://frp.wordpress.org/plugins/tags/widget/)
 *  [Advanced View](https://frp.wordpress.org/plugins/get-user-custom-field-values/advanced/)

## Ratings

 3.7 out of 5 stars.

 *  [  2 5-star reviews     ](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/?filter=2)
 *  [  1 1-star review     ](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/get-user-custom-field-values/reviews/)

## Contributors

 *   [ Scott Reilly ](https://profiles.wordpress.org/coffee2code/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/get-user-custom-field-values/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ARCFJ9TX3522)