Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

Entries & ReportsListing Entries
Get a Value from an Entry

Get a Value from an Entry

Use this shortcode to get the value from a single field entry and display it in a page, post, View or form field. This can be particularly helpful in auto-populating forms for your users.

Usage

Insert the following shortcode in any page, post, View, or field.

[frm-field-value field_id=x user_id=current]

'x' = ID or field key of the field that holds the value you would like to retrieve. If you do not include one of the user_id, entry, or ip parameters, this will retrieve the most recent entry submitted by any user .

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Parameters

Required

  • field_id

    ID or key of the field that holds the value you would like to retrieve. Each field_id is unique, irrespective of the form

    [frm-field-value field_id=x]

You may also include one of these three options in the shortcode:

  • user_id

    Get a value from the most recent entry submitted by a specific logged-in user. You may set user_id=current to retrieve the most recent entry submitted by the current user. This is particularly helpful in auto-populating forms for your users.

    [frm-field-value field_id=x user_id=current]
  • ip

    Get a value from the most recent entry submitted from a specific IP address. You can specify an IP address or use ip=1 to use the IP of the current user. This does not require users to be logged in.

    [frm-field-value field_id=x ip=1]
  • entry

    Get a value from a specific entry ID or key. If the entry ID/key is in the URL like this: ?pass_entry=12345, you can retrieve the ID from the URL like this: entry=pass_entry. You may also pass the entry ID/key as a parameter in a form or View shortcode.

    [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"]

    To get the value from a specific entry ID/key filtered by the current logged-in user, use both the entry and the user_id parameters.

    [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 retrieve.

    [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 will return the html, but it can be turned off with html=0. This will 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 your User ID field ID/key.

    [frm-field-value field_id=x show=id]

    Alternatively, you can 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]
Note: When using params for frm-field-value (e.g., field_id and entry), the param is treated as missing if they're left blank or set to 0, and the shortcode will be evaluated accordingly.

Examples

Automatically populate a date field

By default, the [frm-field-value field_id=x user_id=current] shortcode will display 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, you can use these parameters to pull specific parts of the address field using the frm-field-value shortcode. In the Address field options, insert the frm-field-value shortcode in the Default Value box for each specific field. Get Value Address Field Options In these examples, replace 155 with the field ID/key of the address field from the entry where 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]

Get Value Autopopulate Address Field

Using truncate

Use the truncate parameter to specify the number of characters. Replace x with the field ID/key of your field from the entry where 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 will be "..." but can be changed with the more_text parameter.
    [frm-field-value field_id=x truncate=100 more_text="...Read More"]

Limitations

  • Using [frm-field-value field_id=x truncate=1] will truncate the text to 50 characters. Use this code snippet if you want to override this.
  • This shortcode currently does not work with repeater fields.
Learn where to put the code when adding a custom PHP function to your site.

Use a value in a conditional statement

You can use [frm-field-value] in conditional statements using the built-in frm-condition shortcode.
  1. Create a new shortcode that allows values from frm-field-value to be used in conditional statements. You can use any parameters in this shortcode that you can use above, plus equals.
    [maybe-frm-field-value field_id=x user_id=current equals=5]show it[/maybe-frm-field-value]
  2. 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;
}

Add custom truncate

To add a custom truncate option to the [frm-field-value] shortcode, follow 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;
}

PHP Alternative

Get a value by user ID

FrmProEntriesController::get_field_value_shortcode(array('field_id' => x, 'user_id' => 'current')); Replace x with the ID or field key of the field that holds the value you would like to retrieve.

Get a value by entry ID

FrmProEntriesController::get_field_value_shortcode(array('field_id' => x, 'entry' => $entry_id)); Replace x with the ID or field key of the field that holds the value you would like to retrieve. Make sure $entry_id is set in your code.

Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2025 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Special offer unlocked.
    Get 55% OFF!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms