Formidable Forms

The Most Advanced WordPress Forms Plugin and Form Builder

  • Features
  • Pricing
  • Blog
  • Support
  • Login
  • Get Formidable Forms

Get a Value from an Entry

Last Updated: April 28, 2020

Knowledge Base → Entries → Listing Entries → 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 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 .

Parameters

Required

  • field_id

    ID or key of the field that holds the value you would like to retrieve.

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. Usage: [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. Usage: [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. Usage: [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"]

Optional

Formidable Forms is the best WordPress Form Builder plugin. Get it for free!
  • show

    Get the entry ID from a Dynamic field by using show=id. This allows you to autopopulate Dynamic fields. Usage: [frm-field-value field_id=x user_id=current show=id].
    Alternatively, you can use show=value to get the saved value from a field with separate values. Usage: [frm-field-value field_id=x user_id=current show=value]

  • 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. Usage: [frm-field-value field_id=x user_id=current html=0]

  • default

    Insert a default value in case there isn't a value to retrieve. Usage: [frm-field-value field_id=x user_id=current default="Your name"]

  • format

    Specify a format for date or time fields. Usage: [frm-field-value field_id=x user_id=current format="Y-m-d"]

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. In order to automatically populate a date field with the frm-field-value shortcode, you can use [frm-field-value field_id=x user_id=current format="Y-m-d"].

Automatically populate an address field

In order 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

Limitations

This shortcode currently does not work with repeater fields.

Related Customizations

Use a value in a conditional statement

Note: you can now use [frm-field-value] in conditional statements using the built-in frm-condition shortcode. https://formidableforms.com/knowledgebase/compare-two-values-for-display/

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]

Then 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.

Usage example: [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;
}

You can also get the total of fields using stats, as in this code example:

https://formidableforms.com/knowledgebase/add-field-totals-and-statistics/#kb-combined-total-for-two-fields

And you can get the sum of fields in the same form using this code example:

https://formidableforms.com/knowledgebase/php-examples/#kb-calculate-a-total-in-view

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 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 of the field that holds the value you would like to retrieve. Make sure $entry_id is set in your code.

  • Usage
  • Parameters
    • field_id
    • user_id
    • ip
    • entry
    • show
    • html
    • default
    • format
  • Examples
    • Automatically populate a date field
    • Automatically populate an address field
  • Limitations
  • Related Customizations
    • Use a value in a conditional statement
    • Get the total of two or more fields
  • PHP Alternative
    • Get a value by user ID
    • Get a value by entry ID
Categories
×

Categories

  • Installation & Getting Started
  • Account Management
  • Forms
  • Entries
  • Views
  • Styles
  • Importing & Exporting
  • Add-Ons
  • Extend Formidable Forms
Install Formidable Lite

Using WordPress and want to get Formidable Forms for free?

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.

Take on bigger projects Right Now

Get the tools you need to revolutionize your workflow and architect a masterpiece. Build the most advanced WordPress forms and actually use the data you collect in meaningful ways.

Get the most advanced WordPress form plugin and the only form builder with integrated Views.

Get Formidable Forms Now

Resources

  • Community
  • Affiliates
  • Contact

Top Features

  • Front End Editor
  • Repeating Fields
  • Views from Entries
  • Calculator Forms
  • Conditional Logic
  • Visual Form Styler
  • Form Templates
  • User Submitted Posts
  • File Upload Forms
  • Spam Protection
  • Multi Page Forms
  • Surveys & Polls
  • Form Graphs & Charts
  • Save and Continue
  • Mobile Forms
  • Stripe Forms
  • PayPal Forms
  • WooCommerce Forms
  • MailChimp Forms
  • User Registration
  • Signature Forms
  • Bootstrap Forms
  • Quiz Maker
  • Zapier Forms
  • Salesforce Forms
  • HubSpot Forms
  • API Webhooks
  • Multilingual Forms
  • Directories

Company

  • About Us
  • Giving Back
  • Careers
  • Newsletter
  • Blog

Copyright © 2021 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.
Privacy Policy | Terms of Service | Sitemap

Join 300,000+ using Formidable Forms to create form-focused solutions fast. Get Started