Use this shortcode to get a value from an entry and display it in a page, post, View, or form field. It gets the value of a single field. This is helpful for automatically filling in forms for your users.
Upgrade your WordPress site with powerful, flexible forms.
Usage
Insert the following shortcode in any page, post, View, or field.
[frm-field-value field_id=x user_id=current]
Replace x with the ID or key of the field that holds the value you want to get. If you don't include the user_id, entry, or ip parameter, the shortcode gets the value from the most recent entry submitted by any user.
From Idea to Reality in Minutes. Build Powerful Forms, Dashboards, Apps and More.
Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.
Parameters
Who can see the value
Since Formidable Forms 7.0, the shortcode checks who is viewing the page when it gets a value from a specific entry. This keeps one user's entry values from showing to other visitors.
The check happens when you use the entry or entry_id parameter, user_id with a user ID, or ip with an IP address. The value then shows only to:
- Users who can view entries in the admin area (administrators by default).
- The person who submitted the entry. Since 7.0.1, that includes a logged-out visitor, in the same browser, for 1 hour after they submit it.
Everyone else, including other logged-out visitors, sees nothing, or the default value when you set one. The same check applies to [frm-condition source=frm-field-value] and to the PHP alternative.
Since 7.0.1, a field's Default Value shortcode shows to every visitor when it points to a fixed entry, user, or IP address, such as entry=25. It still checks who is viewing when the entry comes from the page address or the form shortcode, such as entry=pass_entry. It also checks who is viewing for a value from a Password or Credit Card field.
Two uses work the same way for every visitor as before 7.0: a shortcode without the user_id, entry, or ip parameter, and user_id=current. With ip=1, a logged-out visitor sees only the most recent entry submitted from their IP address while logged out.
To show a value to more visitors, use the frm_field_value_requires_ownership hook:
- When a field's values are meant to be public, such as a business name in a directory, show that field's value to every visitor.
- When only some entries are meant to be public, show values from chosen entries to every visitor.
Required
field_id
ID or key of the field that holds the value you want to get. Each field ID is unique, whatever form the field is in.
[frm-field-value field_id=x]
You can also include these parameters to choose the entry. Use one of them, or combine entry with user_id=current:
user_id
Get a value from the most recent entry submitted by a specific logged-in user. Set user_id=current to get the most recent entry submitted by the current user, for example to fill in a form with their earlier answers.
[frm-field-value field_id=x user_id=current]
A specific user ID, such as user_id=12, returns a value only to administrators and to that user when they're logged in. user_id=current works the same way for every logged-in user. Learn more about who can see the value.
ip
Get a value from the most recent entry submitted from a specific IP address. Enter an IP address, or use ip=1 to use the IP address of the current visitor. Visitors don't need to be logged in.
[frm-field-value field_id=x ip=1]
With ip=1, a logged-out visitor sees only the most recent entry submitted from their IP address while logged out. A logged-in visitor sees the most recent entry from their IP address that they submitted, or that was submitted while logged out. Administrators see the most recent entry from that IP address, whoever submitted it.
An IP address you enter, such as ip="203.0.113.5", returns a value only to administrators and to the person who submitted the entry, including a logged-out visitor in the same browser for 1 hour.
entry
Get a value from a specific entry ID or key. If the entry ID or key is in the page address, like ?pass_entry=12345, use entry=pass_entry to get it from there.
You can also pass the entry ID or key as a parameter in a form or View shortcode. The entry_id parameter works the same way as entry.
[frm-field-value field_id=x entry="140"]
[frm-field-value field_id=x entry="entry_param"]
[frm-field-value field_id=x entry="entry-key"]
For example, to pass the entry in a form shortcode, add your own parameter to it, such as entry_param. Replace 12345 with the entry ID or key.
[formidable id=x entry_param=12345]
Then use the same parameter name in a field's default value in that form.
[frm-field-value field_id=x entry="entry_param"]
A value from a specific entry shows only to administrators and to the person who submitted that entry. This includes entry=pass_entry and a parameter you add to the form shortcode, such as entry_param, even in a field's default value.
A logged-out visitor sees the values from an entry they submitted in the same browser for 1 hour, and other visitors see nothing. To change that time, use the frm_guest_entries_cookie_expiration hook.
To get the value from a specific entry only when it belongs to the current logged-in user, use both the entry and the user_id parameters. The value shows only to the user who submitted the entry. Administrators don't see it unless they submitted the entry.
[frm-field-value field_id=x entry="entry_key" user_id="current"]
Optional
clickable
Create a clickable link to another resource.
[frm-field-value field_id=x clickable="1"]
default
Insert a default value in case there isn't a value to get. This value also shows to visitors who can't see the entry's value.
[frm-field-value field_id=x user_id=current default="Your name"]
format
Specify a format for date or time fields.
[frm-field-value field_id=x user_id=current format="Y-m-d"]
html
Include the HTML for an uploaded file. By default, this shortcode returns the HTML. Use html=0 to return the URL only.
[frm-field-value field_id=x user_id=current html=0]
remove_accents
Get a value without any accent marks.
[frm-field-value field_id=x remove_accents="1"]
sanitize
Convert spaces to dashes and make all the letters lowercase.
[frm-field-value field_id=x sanitize="1"]
sanitize_url
Convert characters into plain text for URLs.
[frm-field-value field_id=x sanitize_url="1"]
show
Get the entry ID from a Dynamic field by using show=id. This allows you to autopopulate Dynamic fields.
[frm-field-value field_id=x user_id=current show=id]
You can also get the ID number from a User ID field by using show=id. Replace x with the ID or key of your User ID field.
[frm-field-value field_id=x show=id]
You can also use show=value to get the saved value from a field with separate values.
[frm-field-value field_id=x user_id=current show=value]
Examples
Automatically populate a date field
By default, the [frm-field-value field_id=x user_id=current] shortcode displays a date in the format selected in your WordPress settings. To automatically populate a date field with the frm-field-value shortcode, use this shortcode:
[frm-field-value field_id=x user_id=current format="Y-m-d"]
Automatically populate an address field
To automatically populate an address field, use these parameters to get specific parts of the address field with the frm-field-value shortcode. In the Address field options, insert the frm-field-value shortcode in the Default Value box for each part of the address.
In these examples, replace 155 with the ID or key of the address field in the entry you're getting the value from.
- Autopopulate the first line of the Street address
[frm-field-value field_id=155 show=line1]
- Autopopulate the second line of the Street address
[frm-field-value field_id=155 show=line2]
- Autopopulate the City
[frm-field-value field_id=155 show=city]
- Autopopulate the State
[frm-field-value field_id=155 show=state]
- Autopopulate the Zip Code
[frm-field-value field_id=155 show=zip]
- Autopopulate the Country
[frm-field-value field_id=155 show=country]

Using truncate
Use the truncate parameter to set the number of characters. Replace x with the ID or key of the field in the entry you're getting the value from.
- Truncate text to 2 characters.
[frm-field-value field_id=x truncate=2]
- Truncate text to 10 characters.
[frm-field-value field_id=x truncate=10]
- Truncate text to 100 characters.
[frm-field-value field_id=x truncate=100]
- More Text: By default, this is "..." but you can change it with the more_text parameter.
[frm-field-value field_id=x truncate=100 more_text="...Read More"]
PHP alternative
These PHP functions return the same value as the shortcode, with the same check on who can see the value.
Get a value by user ID
FrmProEntriesController::get_field_value_shortcode( array( 'field_id' => x, 'user_id' => 'current' ) );Replace x with the ID or key of the field that holds the value you want to get.
Get a value by entry ID
FrmProEntriesController::get_field_value_shortcode( array( 'field_id' => x, 'entry' => $entry_id ) );Replace x with the ID or key of the field that holds the value you want to get. $entry_id must be set in your code.
The value is returned only when the current user is an administrator or submitted that entry. Otherwise, the function returns an empty value.
Limitations
- Using [frm-field-value field_id=x truncate=1] truncates the text to 50 characters. Use this code snippet to change it.
- This shortcode doesn't work with Repeater fields.
Related customizations
Use a value in a conditional statement
- Create a new shortcode that lets you use values from frm-field-value in conditional statements. You can use any of the parameters above in this shortcode, plus equals.
[maybe-frm-field-value field_id=x user_id=current equals=5]show it[/maybe-frm-field-value]
- Add this code in your theme functions.php or a new plugin to create the new shortcode:
function maybe_frm_value_func( $atts, $content = '' ) { $val = FrmProEntriesController::get_field_value_shortcode($atts); if($val == $atts['equals']){ return $content; }else{ return ''; } } add_shortcode( 'maybe-frm-field-value', 'maybe_frm_value_func' );
Get the total of two or more fields
This shortcode adds the values of the specified fields in the current user's most recent entries and returns the total. The fields can be from different forms or the same form.
[fields-total ids="25,100,113"]
add_shortcode('fields-total','ff_fields_total');
function ff_fields_total($atts){
$defaults = array(
'ids' => '',
'user_id' => 'current',
);
$atts = array_merge($defaults, $atts);
$ids = explode( ',', $atts['ids'] );
unset( $atts['ids'] );
$total = 0;
foreach ( $ids as $id ) {
$atts['field_id'] = $id;
$total += (int)FrmProEntriesController::get_field_value_shortcode($atts);
}
return $total;
}- Use this code example to get the total of fields using stats.
- Use this code example to get the sum of fields in the same form.
Add custom truncate
To add a custom truncate option to the [frm-field-value] shortcode, use the example below.
[frm-field-value field_id=x custom_truncate=1]
add_filter('do_shortcode_tag', 'truncate_frm_field_value', 10, 3);
function truncate_frm_field_value($output, $tag, $attr) {
if ('frm-field-value' === $tag && isset( $attr['custom_truncate'] ) && is_numeric( $attr['custom_truncate'] ) ) {
$output = FrmAppHelper::truncate($output, $attr['custom_truncate'] );
}
return $output;
}Related developer hooks
- Show values from chosen fields or entries to every visitor with the frm_field_value_requires_ownership hook.
- Change how long guests see the entries they submitted with the frm_guest_entries_cookie_expiration hook.