This article contains PHP examples and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
Below are some commonly requested customizations that require PHP. Add these code samples to a new plugin or your theme functions.php at the very bottom, before the last ?> if there is one.
Upgrade your WordPress site with powerful, flexible forms.
Entries
Get multiple entries
$entries = FrmEntry::getAll(array('it.form_id' => 5), ' ORDER BY it.created_at DESC', 8);Create an entry with PHP
This is advanced and is meant for developers experienced with PHP. FrmEntry::create() inserts an entry in the database.
It sanitizes the values, does some checks, and fills in missing values like the date and time. It takes an array as its argument and returns the ID of the new entry, or false if the entry isn't created.
By default, it also returns false when the same form got an entry with the same values in the last 60 seconds. Change this time with the frm_time_to_check_duplicates hook.
Adding this code doesn't create an entry at a set time by itself. An entry is created each time the code runs.
Put it inside a function that a hook calls at the moment you want the entry, such as right after another form is submitted. Code that isn't inside a hook runs on every page load.
When the entry is created, the form's actions set to run when an Entry is created also run, such as email notifications. Their conditional logic still applies. The Confirmation action doesn't run.
FrmEntry::create(
array(
'form_id' => 5, // Replace 5 with your form ID.
'item_key' => 'entry', // Optional. If the key is taken, a number is added, such as entry2.
'frm_user_id' => get_current_user_id(), // Optional. The ID of the user who owns the entry.
'item_meta' => array(
25 => 'value', // Replace 25 with your field ID and 'value' with your value.
26 => 'value',
27 => 'value',
// Add any field IDs here with the value to insert into each one.
),
)
);The frm_user_id value is used only when the code runs for a user who can edit entries, such as an administrator. Otherwise, the entry belongs to the user who is logged in when the code runs, or to no user when a logged-out visitor runs it.
Create an entry in another form
To create an entry in a second form each time someone submits a form, call FrmEntry::create() from the frm_after_create_entry hook. This hook runs after each new entry is saved, including entries from logged-out visitors, drafts, and entries saved as spam. The example skips drafts and spam, so only submitted entries are copied.
add_action( 'frm_after_create_entry', 'frm_copy_entry_to_another_form', 30, 2 );
function frm_copy_entry_to_another_form( $entry_id, $form_id ) {
if ( 5 !== (int) $form_id ) { // Replace 5 with the ID of the form people submit.
return;
}
$entry = FrmEntry::getOne( $entry_id );
if ( ! $entry || 0 !== (int) $entry->is_draft ) { // Skip drafts and spam.
return;
}
$name = FrmEntryMeta::get_entry_meta_by_field( $entry_id, 25 ); // Replace 25 with the ID of a field in that form.
FrmEntry::create(
array(
'form_id' => 6, // Replace 6 with the ID of the form that gets the new entry.
'item_meta' => array(
30 => $name, // Replace 30 with the ID of a field in form 6.
31 => $entry_id, // Replace 31 with the ID of another field in form 6.
),
)
);
}Replace 5 with the ID of the form people submit, and 25 with the ID of the field to copy. Replace 6 with the ID of the form that gets the new entry, and 30 and 31 with the IDs of its fields.
To find a form ID, go to Formidable → Forms and check the ID column. To find a field ID, click the field in the form builder and check the field details.
The check on the form ID also keeps the new entry in form 6 from running this code again.
Validate the values first
To check the values the way a form submission does, validate them, and create the entry only when there are no errors:
$entry = array(
'form_id' => 5, // Replace 5 with your form ID.
'item_key' => 'entry', // Optional. If the key is taken, a number is added, such as entry2.
'item_meta' => array(
25 => 'value', // Replace 25 with your field ID and 'value' with your value.
26 => 'value',
27 => 'value',
),
);
// No browser submits this form, so skip its JavaScript anti-spam check.
add_filter( 'frm_run_antispam', '__return_false' );
$errors = FrmEntryValidate::validate( $entry );
remove_filter( 'frm_run_antispam', '__return_false' );
if ( empty( $errors ) ) {
FrmEntry::create( $entry );
}Validation runs the same checks as a form submission, including the required fields and the spam checks. The JavaScript anti-spam check, which is on by default for new forms, needs a token that only a browser sends. The frm_run_antispam hook turns it off while the code validates the values, and the other spam checks still run.
By default, a value that a content spam check finds, such as a word in the WordPress Disallowed Comment Keys list, doesn't return an error. The same as in a form submission, FrmEntry::create() then saves the entry as spam, and the form actions don't run for it.
Run the code from a hook such as frm_after_create_entry. On an admin page, validation returns "You do not have permission to do that" for a logged-in user.
If this is also a User Registration form, and you want users to be created, open the form's Register User action in Settings → Actions & Notifications. In its Permissions section, check Allow logged-in users to create new users with this form to trigger the new user creation. The role needed will be based on whoever is logged in when the code snippet is run.

Create a file with PHP
This basic PHP example adds an entry to a form with only a file upload field. Create that form first. The File Upload field needs Formidable Forms Pro. Provide 3 variables: file path, file upload field ID, and the form ID. A file upload field requires an attachment ID as input.
Find the form ID in the ID column of Formidable → Forms. Find the field ID on the field in the form builder.
The file must already be in your site's uploads folder, such as wp-content/uploads/2026/11/photo.jpg. Upload it with SFTP or your host's file manager. Do not upload it with Media → Add New, or it shows in the Media Library twice. In $path, use the full server path to the file, such as /var/www/html/wp-content/uploads/2026/11/photo.jpg. To find the uploads part of that path, go to Tools → Site Health → Info and open Directories and Sizes. The Uploads directory location row shows it.
The code adds the file to the Media Library without a title. When you run it with WP-CLI, the Media Library item also shows (no author) and (Unattached). Each time the code runs, it adds the file to the Media Library again. Run it once for each file.
For example, save it in your WordPress folder in a file named create-file.php, and add <?php as its first line. Then run it once with WP-CLI from that folder: wp eval-file create-file.php. WP-CLI needs shell access to your server. WP-CLI shows no message when the code works. To see the result, go to Formidable → Entries and select the form. Delete create-file.php from the server after it runs. If it stays in your WordPress folder, anyone can open it in a browser and see an error that shows your server path. Do not add it as is to functions.php or a plugin. There it runs on every page load and adds a new entry each time.
$path = '...'; // Change this to the full file path we're adding to our file field.
$file_field_id = 24154; // Change this.
$form_id = 1729; // Change this.
$attachment_data = array(
'post_mime_type' => wp_check_filetype( $path )['type'],
'post_status' => 'publish',
);
$new_attachment_id = wp_insert_attachment( $attachment_data, $path );
// Generate the metadata for the attachment, and update the database record.
require_once ABSPATH . 'wp-admin/includes/image.php';
wp_generate_attachment_metadata( $new_attachment_id, $path );
$entry_data = array(
'form_id' => $form_id,
'item_key' => 'entry',
'item_meta' => array(
$file_field_id => $new_attachment_id,
),
);
FrmEntry::create( $entry_data );
Duplicate an entry
Let logged-in users copy one of their entries and edit the copy on the front-end of your site. The form must allow front-end editing for the user's role. In the form builder, go to Settings → Form Permissions and check Allow front-end editing of entries. Then, in Role required to edit one's own entries, select the roles that can copy entries, or Logged-in Users. Both settings are in Formidable Forms Pro. Without Allow front-end editing of entries, the shortcode shows nothing. It also shows nothing to a user whose role is not selected in Role required to edit one's own entries. Learn more about how to set up front-end editing.
Insert the following shortcode on a page where you want the form to be shown in edit mode with the duplicated entry: [duplicate_entry_form id=5 entry_id=duplicate_id field_id=25]
Change 5 to the form id and 25 to the id of the user ID field in that form. entry_id can be the id of the entry to duplicate, or a name to find in the url like ?duplicate_id=40. It works best to create a View that lists entries, then include a link like this in your View Content:
<a href="url-of-page-with-shortcode/?duplicate_id=[id]">Duplicate</a>
Replace url-of-page-with-shortcode with the URL of the page where the [duplicate_entry_form] shortcode is placed.
add_shortcode( 'duplicate_entry_form', 'frm_duplicate_entry_form' );
function frm_duplicate_entry_form( $atts ) {
$atts = shortcode_atts( array( 'id' => 0, 'entry_id' => '', 'field_id' => 0 ), $atts, 'duplicate_entry_form' );
$user_id = get_current_user_id();
$form = FrmForm::getOne( $atts['id'] );
// The form must allow front-end editing for this user's role, or the copy shows a blank form.
if ( ! $user_id || ! $form || ! $form->editable || ! FrmProFieldsHelper::user_has_permission( $form->options['editable_role'] ) ) {
return '';
}
// entry_id is an entry ID, or the name of a URL parameter that holds one.
$old_id = $atts['entry_id'];
if ( ! is_numeric( $old_id ) ) {
$old_id = isset( $_GET[ $old_id ] ) ? $_GET[ $old_id ] : 0;
}
$old_id = absint( $old_id );
$entry = $old_id ? FrmEntry::getOne( $old_id ) : false;
// Copy only an entry from this form that the logged-in user owns, or any entry for users who can edit all entries.
if ( ! $entry || (int) $entry->form_id !== (int) $form->id ) {
return '';
}
if ( (int) $entry->user_id !== $user_id && ! current_user_can( 'frm_edit_entries' ) ) {
return '';
}
// One open copy per user and entry, so a page reload opens the same copy.
$meta_key = 'frm_copy_of_' . $old_id;
$new_entry_id = (int) get_user_meta( $user_id, $meta_key, true );
if ( ! $new_entry_id || ! FrmEntry::getOne( $new_entry_id ) ) {
/* add_filter( 'frm_add_entry_meta', 'autoincrement_on_duplicate' );*/ //Un-comment this line if you have auto increment field in your form
$new_entry_id = FrmEntry::duplicate( $old_id );
/* remove_filter( 'frm_add_entry_meta', 'autoincrement_on_duplicate' );*/ //Un-comment this line if you have auto increment field in your form
update_user_meta( $user_id, $meta_key, $new_entry_id );
// set the new entry to the ID of the current user
global $wpdb;
$user_id_field = absint( $atts['field_id'] );
$wpdb->update( $wpdb->prefix .'frm_items', array( 'user_id' => $user_id ), array( 'id' => $new_entry_id ) );
$wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $user_id ), array( 'item_id' => $new_entry_id, 'field_id' => $user_id_field ) );
}
// The copy was just saved: forget it, so the next click makes a new copy.
global $frm_vars;
if ( isset( $frm_vars['created_entries'][ $form->id ] ) && empty( $frm_vars['created_entries'][ $form->id ]['errors'] ) ) {
delete_user_meta( $user_id, $meta_key );
}
return FrmFormsController::get_form_shortcode( array( 'id' => $form->id, 'entry_id' => $new_entry_id ) );
}
// Un-comment the function below if you have an auto-increment field in your form
/*function autoincrement_on_duplicate( $values ) {
$field_id = 7933; //Replace 7933 with the ID of your Auto increment field
if ( $field_id === (int) $values['field_id'] ) {
$field = FrmField::getOne( $field_id );
$value = $field->default_value;
FrmProFieldsHelper::replace_non_standard_formidable_shortcodes( array( 'field' => $field ), $value );
$values['meta_value'] = $value;
}
return $values;
}*/The shortcode copies an entry only when it is from the form set in id and belongs to the logged-in user. Users who can edit all entries, such as administrators, can copy any entry of that form. Each user has one open copy of each entry, so reloading the page opens the same copy. After the user saves the copy, the link makes a new copy the next time they click it. Without an entry ID in the URL, or for a logged-out visitor, the shortcode shows nothing.
When the page opens, the copy is saved as a new entry at once, before the user clicks Update. With the entry, Formidable Forms Pro also copies its uploaded files, its Repeater rows, and its embedded form entries. If the form has a Create Post action, it also makes a copy of the linked post, with the same status, such as Published.
Delete an entry
To delete one entry, go to Formidable → Entries. Then hover over the entry and click Delete. In the "Permanently delete this entry?" window, click Confirm. To keep the post that is linked to an entry, hover over the entry and click View. Then click Delete without Post. In the "Really delete?" window, click Confirm. Learn more about how to delete entries.
To delete an entry from your own code, use FrmEntry::destroy(). Add this inside the function that decides to delete the entry, such as a hook callback. Do not add it as is to functions.php or a plugin, because there it runs on every page load. Replace 123 with the ID of the entry and 5 with the ID of its form. The code deletes the entry only when it belongs to that form. The form check doesn't check who runs the code. If a visitor can make the code run, such as with a link or a form, also check that the user can delete entries: current_user_can( 'frm_delete_entries' ).
- Its saved values. With Formidable Forms Pro, it also deletes its Repeater rows and its embedded form entries.
- With Formidable Forms Pro, the post linked to it, such as one a Create Post action made. Posts and pages go to the trash, unless the post is already in the trash or the site has the trash turned off. Other post types are deleted for good.
- With Formidable Forms Pro, its uploaded files, when the File Upload field has Permanently delete old files when replaced or when the entry is deleted checked. A file is deleted from the Media Library even if you use it somewhere else on your site.
With Formidable Forms Pro, it also runs the form actions set to run when an entry is deleted. These actions don't run for a draft or spam entry.
$entry_id = 123; // change 123 to the ID of the entry to delete
$form_id = 5; // change 5 to the ID of the form the entry belongs to
$entry = FrmEntry::getOne( $entry_id );
if ( $entry && (int) $entry->form_id === $form_id ) {
FrmEntry::destroy( $entry_id );
}Delete User entries when a User is deleted
Automatically delete entries from a form when a user account is deleted from your WordPress site. The entries are deleted even when you choose to attribute the user's content to another user. The user's entries in other forms and the entries of logged-out visitors stay.
- Its saved values. With Formidable Forms Pro, it also deletes its Repeater rows and its embedded form entries.
- With Formidable Forms Pro, the post linked to it, such as one a Create Post action made. Posts and pages go to the trash, unless the post is already in the trash or the site has the trash turned off. Other post types are deleted for good.
- With Formidable Forms Pro, its uploaded files, when the File Upload field has Permanently delete old files when replaced or when the entry is deleted checked. A file is deleted from the Media Library even if you use it somewhere else on your site.
With Formidable Forms Pro, it also runs the form actions set to run when an entry is deleted. These actions don't run for a draft or spam entry.
add_action( 'delete_user', 'my_delete_user' );
function my_delete_user( $user_id ) {
$user_id = (int) $user_id;
if ( ! $user_id ) {
return; // 0 would match the entries of logged-out visitors
}
$form_id = 19; //change 19 to the id of the form you would like to delete entries from
$entry_ids = FrmDb::get_col( 'frm_items', array( 'user_id' => $user_id, 'form_id' => $form_id ) );
foreach ( $entry_ids as $entry_id ) {
FrmEntry::destroy( $entry_id );
}
}Update a field value
When a field is used in a post, use the WordPress functions like update_post_meta or wp_update_post.
This code sets the value of one field in an entry. Replace 123 with the field ID and 25 with the entry ID. If the entry has no value for that field yet, the code adds it.
$field_id = 123; // Replace 123 with your field ID.
$entry_id = 25; // Replace 25 with your entry ID.
$new_value = 'Value here';
$meta_id = FrmDb::get_var( 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id' => $field_id ), 'id' );
if ( $meta_id ) {
FrmEntryMeta::update_entry_meta( $entry_id, $field_id, null, $new_value );
} else {
FrmEntryMeta::add_entry_meta( $entry_id, $field_id, null, $new_value );
}Get entry id from post id
$entry_id = FrmDb::get_var( 'frm_items', array( 'post_id' => $post_id_here ), 'id' );Get form id from entry id
$entry = FrmEntry::getOne( $entry_id );
$form_id = $entry->form_id;Get field values as an array
Checkboxes fields, and Dropdown and Lookup fields with Multiselect turned on, save several values in one entry. The [frm-field-value] shortcode, and FrmProEntriesController::get_field_value_shortcode() in PHP, return these values as one line of text separated by commas, even with return_array=1.
When an option contains a comma, such as "Red, dark", the text can't be split back into the right values. Get the saved values as an array instead:
$entry_id = 25; // Replace 25 with the ID of the entry.
$field_id = 100; // Replace 100 with the ID of the field.
$values = FrmEntryMeta::get_entry_meta_by_field( $entry_id, $field_id );
if ( is_array( $values ) ) {
foreach ( $values as $value ) {
// Each $value is one saved option, such as "Red, dark".
}
}When the field uses separate values, the array holds the saved values, not the option labels. A field that saves a single value, such as a Text field, returns a string. A Checkboxes field with 1 box checked still returns an array with 1 item.
If you already have the entry from FrmEntry::getOne( $entry_id, true ), the same array is in $entry->metas[ $field_id ].
If the form has a Create Post action, use FrmProEntryMetaHelper::get_post_or_meta_value() instead. It also reads values that are saved in the post, such as a field mapped to the post title. It needs Formidable Forms Pro.
A Tags field, or a field mapped to a category or other taxonomy, returns a text string instead of an array. The string lists term links separated by commas.
$entry = FrmEntry::getOne( $entry_id );
$field = FrmField::getOne( $field_id );
$values = FrmProEntryMetaHelper::get_post_or_meta_value( $entry, $field );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.
Fields
Get field ID from Key
$field_id = FrmField::get_id_by_key('keyhere');Get field Key from ID
$field_key = FrmField::get_key_by_id( 5 );Display a Field Description
Do you want to display a field description in a View or email? The content of an HTML field is also saved as a field description. Use this shortcode in places such as a page or View: [frm-show-description field_id=x]
add_shortcode( 'frm-show-description', 'frm_show_description' );
function frm_show_description( $atts ) {
if ( ! isset( $atts['field_id'] ) || ! is_numeric( $atts['field_id'] ) ) {
return '';
}
$field_info = FrmField::getOne( $atts['field_id'] );
if ( ! $field_info ) {
return '';
}
return $field_info->description;
}Views
Compare two fields in View
Use this shortcode to compare two fields in your View.
add_shortcode('compare', 'compare_func');
function compare_func($atts, $content=""){
extract(shortcode_atts(array('val1' => '', 'val2' => '', 'type' => '=='), $atts));
if ( $type == 'greater_than' ) {
$type = '>';
} else if ( $type == 'less_than' ) {
$type = '<';
} else if ( $type == 'equals' ) {
$type = '==';
}
if ( !FrmFieldsHelper::value_meets_condition($val1, $type, $val2) ) {
$content = '';
}
return $content;
}Usage:
[compare val1="[x]" type="==" val2="[y]"]content here[/compare]
Replace x and y with your field ids and replace == with your condition. To check if the two values are equal, use ==. You can also use type="greater_than", less_than, or equals.
Calculate a Total in View
After adding this code to your theme functions.php or a new plugin, calculate the sum of any number of fields inside of a View using this shortcode: [sum vals="[125],[126],[127]"]. Replace 125, 126, and 127 with field IDs from your form. This is only meant to be used to add fields. This cannot be used to subtract, multiply, or divide fields without further customization.
add_shortcode('sum','my_entry_count');
function my_entry_count($atts){
extract( shortcode_atts(array(
'vals' => '0',
), $atts ) );
$val_array = explode(',', $vals);
$total = array_sum($val_array);
return $total;
}Show View content in tabs
Show each entry's details in tabs, such as a bio in one tab and contact details in another. This code adds 2 shortcodes: [tabs] holds a set of tabs, and each [tab title="…"] inside it is one tab. Field shortcodes inside a tab show the values of the current entry, and each entry in the View gets its own set of tabs.
Add the tabs shortcodes
add_shortcode( 'tabs', 'ff_tabs_shortcode' );
add_shortcode( 'tab', 'ff_tab_shortcode' );
add_action( 'wp_footer', 'ff_tabs_assets' );
function ff_tabs_shortcode( $atts, $content = '' ) {
global $ff_tabs, $ff_tabs_used;
$ff_tabs_used = true;
$atts = shortcode_atts( array( 'label' => 'Tabs' ), $atts, 'tabs' );
// A random id per set, so sets loaded later with AJAX get their own ids.
$set = 'content-tabs-' . wp_rand();
// Each [tab] inside adds itself to $ff_tabs.
$ff_tabs = array();
do_shortcode( $content );
$tabs = $ff_tabs;
$ff_tabs = null;
if ( ! $tabs ) {
return '';
}
$buttons = '';
$panels = '';
foreach ( $tabs as $i => $tab ) {
$id = $set . '-' . $i;
$selected = ( 0 === $i );
$buttons .= sprintf(
'<button type="button" role="tab" id="%1$s-tab" aria-controls="%1$s" aria-selected="%2$s" tabindex="%3$s">%4$s</button>',
$id,
$selected ? 'true' : 'false',
$selected ? '0' : '-1',
esc_html( $tab['title'] )
);
$panels .= sprintf(
'<div role="tabpanel" id="%1$s" aria-labelledby="%1$s-tab" tabindex="0"%2$s>%3$s</div>',
$id,
$selected ? '' : ' hidden',
$tab['content']
);
}
return '<div class="content-tabs"><div role="tablist" aria-label="' . esc_attr( $atts['label'] ) . '">' . $buttons . '</div>' . $panels . '</div>';
}
function ff_tab_shortcode( $atts, $content = '' ) {
global $ff_tabs;
if ( ! is_array( $ff_tabs ) ) {
return ''; // A [tab] outside [tabs] shows nothing.
}
$atts = shortcode_atts( array( 'title' => '' ), $atts, 'tab' );
$ff_tabs[] = array(
'title' => $atts['title'],
'content' => do_shortcode( $content ),
);
return '';
}
function ff_tabs_assets() {
global $ff_tabs_used;
if ( empty( $ff_tabs_used ) ) {
return;
}
echo <<<'TABS'
<style>
.content-tabs [role="tablist"] { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid #ccc; }
.content-tabs [role="tab"] { position: relative; top: 1px; padding: 8px 16px; border: 1px solid #ccc; background: #f6f7f7; color: inherit; font: inherit; cursor: pointer; }
.content-tabs [role="tab"][aria-selected="true"] { border-bottom-color: #fff; background: #fff; font-weight: bold; }
.content-tabs [role="tabpanel"] { padding: 16px 0; }
</style>
<script>
function ffSelectTab( tab ) {
tab.parentNode.querySelectorAll( '[role="tab"]' ).forEach( function( t ) {
var on = ( t === tab );
t.setAttribute( 'aria-selected', on ? 'true' : 'false' );
t.tabIndex = on ? 0 : -1;
tab.closest( '.content-tabs' ).querySelector( '#' + t.getAttribute( 'aria-controls' ) ).hidden = ! on;
} );
}
document.addEventListener( 'click', function( e ) {
var tab = e.target.closest( '.content-tabs [role="tab"]' );
if ( tab ) {
ffSelectTab( tab );
}
} );
document.addEventListener( 'keydown', function( e ) {
var tab = e.target.closest( '.content-tabs [role="tab"]' );
if ( ! tab ) {
return;
}
var tabs = Array.prototype.slice.call( tab.parentNode.children );
var keys = { ArrowRight: tabs.indexOf( tab ) + 1, ArrowLeft: tabs.indexOf( tab ) - 1, Home: 0, End: tabs.length - 1 };
if ( ! ( e.key in keys ) ) {
return;
}
e.preventDefault();
var next = tabs[ ( keys[ e.key ] + tabs.length ) % tabs.length ];
next.focus();
ffSelectTab( next );
} );
</script>
TABS;
}When the page loads, only the first tab of each set is open. Click a tab button to open that tab.
Keyboard users can also move between the tabs with the arrow keys, Home, and End. The tabs use the roles and keys of the WAI-ARIA tabs pattern.
The CSS and JavaScript load only on pages that show tabs.
Each set has a label, the name that screen readers use for it. The default label is Tabs. To change it, add label to the set: [tabs label="Team details"].
Don't type a double quote inside a tab title, because the button then shows no text. Write " instead, as in [tab title="Say "hi""], or put the title in single quotes: [tab title='Say "hi"']. Both show Say "hi" on the button.
To show tabs in a View, you need the Views add-on and a Classic View for your form. Learn how to create a View. Then:
- Go to Formidable → Views and click the title of your Classic View.
- Click the dashed listing content box below Add Before Content. If the View already has content, the box shows the first entry's values, not the shortcodes. This opens the Edit Listing Page Content window.
- Select the Code tab and add the tabs with your field shortcodes. In this example, 25 is a Name field, 26 is a Paragraph field, 27 is an Email field, and 28 is a Phone field.
<h3>[25]</h3> [tabs] [tab title="About"][26][/tab] [tab title="Contact"]Email: [27]<br>Phone: [28][/tab] [/tabs]
Replace 25, 26, 27, and 28 with the field IDs from your form. The window lists them on the right, under Fields.
- Click Update at the bottom of the window. This saves the View, so you do not need the Update button at the top of the page.
- Open the page that shows the View. Learn how to publish a View if it isn't on a page yet.

The shortcodes also work on a page or post outside a View. Each tab set on a page works on its own, so a click in one set doesn't change the others. This includes the sets a View loads with AJAX pagination or its Load More button.
A tab set can't go inside a tab of another set.
Forms
Use pre 3.0 theme preview
Version 3.0+ uses an auto generated page from your theme. If you need the old page to keep working, add this function to your site.
Open the page with the form key in the URL, such as ?form=contact-form. With a form ID, or a key that no form has, the page shows its own content.
add_filter( 'the_content', 'page_route', 10 );
function page_route( $content ) {
global $post;
$preview_page_id = 25; // change 25 to the ID of your form preview page
if ( $post && $post->ID == $preview_page_id && isset( $_GET['form'] ) ) {
$preview = FrmFormsController::page_preview();
if ( null !== $preview ) {
$content = $preview;
}
}
return $content;
}Use the old preview links
Get form ID by key
$form_id = FrmForm::get_id_by_key('keyhere');Form Templates
Hide or delete form templates
This guide explains how to hide specific form templates on the Formidable → Form Templates page by using a code snippet.
- Identify the template IDs you want to hide. On the Formidable → Form Templates page, right-click the template name and select Inspect. A few lines above the highlighted name, the template's
<li class="frm-card-item" data-id="…">element holds its ID. For example, the Car Payment Calculator template has an ID of 20874733.

- Insert the following code snippet into your theme's functions.php file or a custom plugin:
add_filter('http_response', function( $response, $parsed_args, $url ) { // Check if the URL starts with the specific base if ( strpos( $url, 'https://formidableforms.com/wp-json/form-templates/v1/') !== 0 ) { return $response; } $data = json_decode( $response['body'], true ); // Check if decoding was successful and the data is an array if ( ! is_array( $data ) ) { return $response; } // Replace 20872681 and 20873681 with the template IDs to be removed $template_ids_to_remove = array( 20872681, 20873681 ); foreach ( $template_ids_to_remove as $template_id ) { unset( $data[ $template_id ] ); } $response['body'] = json_encode( $data ); return $response; }, 10, 3); - Clear the cache: go to Formidable → Global Settings → General Settings and click Check for a recent purchase. This clears the cache and shows the updated list of templates. Formidable Forms Pro adds this link. Without Pro, the list of templates updates by itself within 12 hours.
Note: Since this filter hooks into the API response when we make a web request for new data, clearing the cache is necessary.
Admin area
Expand the WordPress menu sidebar
Formidable uses the fullscreen mode set in the block builder. This code always shows the WordPress Menu when editing Forms and Views.
add_filter( 'frm_admin_full_screen_class', 'frm_keep_full_screen' );
function frm_keep_full_screen(){
return '';
}Remove the SMTP menu
This code will remove the SMTP option from the Formidable menu.
add_action( 'admin_menu', 'frm_remove_smtp_menu', 9999);
function frm_remove_smtp_menu() {
remove_submenu_page( 'formidable', 'formidable-smtp' );
}Bulk Delete Formidable log entries
The Logs add-on has its own tools to delete log entries, so you don't need code to delete them.
- To delete all log entries for good, go to Formidable → Logs. Click Delete All Logs. Then click Confirm.
- To delete old log entries every 30 days, go to Formidable → Global Settings → Logs. Check Automatically delete log entries every 30 days. Then click Update.
Learn more about how to delete logs. The automatic delete keeps the log entries from the last week. To keep a different period, add this code and change -3 days. Learn more about the frm_logs_cron_remains hook.
add_filter( 'frm_logs_cron_remains', 'frm_keep_recent_logs' );
function frm_keep_recent_logs() {
return '-3 days'; // keep the logs from the last 3 days
}Prevent WordPress from loading jQuery migrate
jQuery migrate is a file that gets loaded automatically with WordPress. It's used to help transition from old versions of jQuery to a newer version. It's useful for testing but isn't necessary for a form to work. Use this code snippet to prevent jQuery migrate from loading on the front end, and from the Formidable preview page.
function remove_jquery_migrate( $scripts ) {
$should_remove_jquery_migrate = ! is_admin() || FrmAppHelper::is_preview_page();
if ( isset( $scripts->registered['jquery'] ) && $should_remove_jquery_migrate ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) {
// Check whether the script has any dependencies
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );Disable the summary email
Use this code snippet to disable the summary emails set up in the Global settings.
add_action(
'init',
function() {
$settings = FrmAppHelper::get_settings();
$settings->summary_emails = 0;
}
);While the snippet runs, the Send monthly and yearly summary emails with form and payment stats. checkbox in Formidable → Global Settings → Miscellaneous shows as unchecked. If you click Update on that page while the snippet runs, the unchecked box is saved. The emails then stay off after you remove the snippet. To turn them on again, remove the snippet, check the box and click Update.
Shortcodes
Get the most selected field value
Get the most selected field value from a specific field. Put [frm-most-selected id=x] in places such as a page, form, or View. Replace x with the ID of a field.
add_shortcode( 'frm-most-selected', 'frm_most_selected_value' );
function frm_most_selected_value( $atts ){
if ( ! isset( $atts['id'] ) || ! is_numeric( $atts['id'] ) ) {
return '';
}
$field = FrmField::getOne( $atts['id'] );
$meta_values = FrmProEntryMeta::get_all_metas_for_field( $field );
// Flatten the saved values. Checkboxes values are saved as an array.
$final_values = array();
foreach ( $meta_values as $meta_val ) {
$meta_val = FrmAppHelper::maybe_unserialize_array( $meta_val );
if ( is_array( $meta_val ) ) {
$final_values = array_merge( $final_values, $meta_val );
} else {
$final_values[] = $meta_val;
}
}
// Get most popular
$count_values = array_count_values( $final_values );
arsort( $count_values );
$popular = array_slice( array_keys( $count_values ), 0, 1, true );
$popular = reset( $popular );
// Get display value
$popular = FrmProEntriesController::filter_display_value( $popular, $field );
return $popular;
}Check parameter value
Use the following code to check if a parameter has a specific value set. Use [if_get_param name="param_name_goes_here" type="equals" value="put_value_here"]Your content[/if_get_param] to show content only if the retrieved value matches the value set in your shortcode.
add_shortcode('if_get_param', 'check_get_param_value');
function check_get_param_value( $atts, $content="" ) {
if ( ! isset( $atts['name'] ) || ! isset( $atts['value'] ) || ! isset( $atts['type'] ) ) {
return $content;
}
$type = $atts['type'];
if ( $type == 'greater_than' ) {
$type = '>';
} else if ( $type == 'less_than' ) {
$type = '<';
} else if ( $type == 'equals' ) {
$type = '==';
} else if ( $type == 'not_equal' ) {
$type = '!=';
}
$get_value = isset( $_GET[ $atts['name'] ] ) ? $_GET[ $atts['name'] ] : '';
if ( ! FrmFieldsHelper::value_meets_condition( $get_value, $type, $atts['value'] ) ) {
$content = '';
}
return do_shortcode( $content );
}Show parameter value on a page
Use the following code to show the value of a URL parameter on a WordPress page or post.
Usage: [show_param param="color"]
add_shortcode('show_param', 'ff_show_param');
function ff_show_param( $atts ) {
if ( ! isset( $atts['param'] ) || ! isset( $_GET[ $atts['param'] ] ) ) {
return '';
}
$get_value = wp_unslash( $_GET[ $atts['param'] ] );
if ( ! is_string( $get_value ) ) {
return '';
}
return esc_html( $get_value );
}Show content based on current user's role
The following shortcode, when used with frm-condition, can show content conditionally based on the current user's role. The [has_role] shortcode will return 1 if the current user has the WordPress capability set in the "cap" param and 0 if the user does not. By default, the shortcode checks if the user is an admin, but any WordPress capability can be used to check for any WordPress role you want. Please see the Codex on WordPress roles and capabilities for more information.
Usage:
[frm-condition source=has_role equals=1]content for admins[/frm-condition]
[frm-condition source=has_role equals=0]content for non-admins[/frm-condition]
[frm-condition source=has_role cap="read_private_pages" equals=1]content for editors and higher[/frm-condition]
add_shortcode( 'has_role', 'ff_has_role' );
function ff_has_role( $atts ) {
$atts = shortcode_atts( array(
'cap' => 'activate_plugins',
), $atts, 'has_role' );
return current_user_can( $atts['cap'] ) ? 1 : 0;
}Show content if current user is logged in
The following shortcode, when used with frm-condition, can show content only to logged-in users or only to visitors who aren't logged in. The [is_logged_in] shortcode will return 1 if the current user is logged in and 0 if not.
Usage:
[frm-condition source=is_logged_in equals=1]content for logged-in users[/frm-condition]
[frm-condition source=is_logged_in equals=0]content for visitors who aren't logged in[/frm-condition]
add_shortcode( 'is_logged_in', 'ff_is_logged_in' );
function ff_is_logged_in () {
return is_user_logged_in() ? 1 : 0;
}Show content based on the current month
The following shortcode, when used with frm-condition, can show content based on the month in which the page, post, View, or other content is being viewed. The [current_month] shortcode will return the number of the current month, using typical month numbering, where January is 1 and December is 12.
Usage:
[frm-condition source=current_month equals=1]content you want users to see in January[/frm-condition]
[frm-condition source=current_month greater_than=6]content you want users to see in July through December[/frm-condition]
add_shortcode( 'current_month', 'ff_current_month' );
function ff_current_month() {
return wp_date( 'n' ); // The month in the site's time zone.
}Get current page's slug
Use the following shortcode to display the slug of the current page, post, or custom post type. To show the slug of another one, use the post_id param with its post ID.
Usage:
[page_slug] - displays current page's slug
[page_slug post_id=12] -- displays slug of page
[page_slug post_id=[post_id]] -- displays the slug of the slug of the current entry's page, post, or custom post type in a View
function get_page_slug( $atts ){
if ( ! empty( $atts['post_id'] ) ) {
return get_post_field( 'post_name', ( int ) $atts['post_id'] );
}
return get_post_field( 'post_name');
}
add_shortcode( 'page_slug', 'get_page_slug' );Show shortcode for a specified date range
You can use this shortcode to show a particular form, View, or other shortcode only during a specific date range. Before the beginning of the date range, you can display a message, if you like. After that date, you can display a different message, if you like.
- Use double quotes for the params in the [show-in-date-range] shortcode.
- Set the shortcode param to the shortcode you want to use, without the brackets. Use single quotes for params within the shortcode param.
- Set the start and end params to valid date strings that work with strtotime. If you don't want a start or an end date, you can omit the corresponding param.
- Set the early-msg and late-msg params to the messages you want to show the user before and after the date range.
Usage:
[show-in-date-range shortcode="formidable id='60' title='1' color='red' book='Pride & Prejudice'" start="November 1, 2018" end="November 30, 2018" early-msg="Signups for the dinner will begin November 1." late-msg="Sorry! It's too late to sign up for this year's dinner. We'd love to have you join us next year."]
add_shortcode( 'show-in-date-range', 'ff_show_in_date_range' );
function ff_show_in_date_range( $atts ) {
if ( empty( $atts['shortcode'] ) ) {
return 'No shortcode was entered.';
}
if ( ! empty( $atts['start'] ) ) {
$start = strtotime( $atts['start'] );
if ( ! $start ) {
return 'Start date is not a valid date.';
}
if ( time() < $start ) {
return isset( $atts['early-msg'] ) ? $atts['early-msg'] : '';
}
}
if ( ! empty( $atts['end'] ) ) {
$end = strtotime( $atts['end'] );
if ( ! $end ) {
return 'End date is not a valid date.';
}
if ( time() > $end ) {
return isset( $atts['late-msg'] ) ? $atts['late-msg'] : '';
}
}
return do_shortcode( '[' . $atts['shortcode'] . ']' );
}Show display names from a list of user ids
You can use the [user_info] shortcode to show the corresponding display names (or other user data) of a comma-separated list of user ids or a single user id.
Parameters:
- users: a comma-separated list of user ids. In a View, the list can be taken from a field.
- data: the user data you want to display. Default: display_name. The code shows only the user data in its $allowed list: display_name, user_login, user_nicename, user_email, user_url, first_name, last_name, and nickname. For other data, the shortcode shows nothing. To show other public user data, add its name to the list. Never add user_pass, which holds the password hash. You can see a list of some useful options at the bottom of this page in the WordPress docs: https://developer.wordpress.org/reference/functions/get_userdata/
- backup: if the data you want to display isn't available for a user, this backup data will be displayed instead. Default: user_login. It also must be in the $allowed list.
Usage:
[user_info users="20, 32, 41"] -- shows the display names for the listed users
[user_info users="[100]"] -- shows the display names for the users whose ids are in a comma-separated list in field 100
[user_info users="20,112,128" data="user_email" backup="user_login"] -- shows the emails of the listed users
function user_info_shortcode( $atts ) {
$atts = shortcode_atts( array(
'users' => false,
'data' => 'display_name',
'backup' => 'user_login',
), $atts );
// The user data the shortcode can show. Never add user_pass or other private data.
$allowed = array( 'display_name', 'user_login', 'user_nicename', 'user_email', 'user_url', 'first_name', 'last_name', 'nickname' );
if ( ! $atts['users'] || ! in_array( $atts['data'], $allowed, true ) ) {
return '';
}
if ( ! in_array( $atts['backup'], $allowed, true ) ) {
$atts['backup'] = '';
}
$users = explode( ',', $atts['users'] );
$users_info = array_reduce( $users, function ( $result, $current ) use ( $atts ) {
$current_user = get_userdata( (int) trim( $current ) );
if ( ! $current_user ) {
return $result;
}
$separator = ( '' === $result ) ? '' : ', ';
$data = $current_user->{$atts['data']};
if ( ! $data ) {
if ( empty( $atts['backup'] ) || empty( $current_user->{$atts['backup']} ) ) {
return $result;
}
$data = $current_user->{$atts['backup']};
if ( ! $data ) {
return $result;
}
}
return $result . $separator . esc_html( $data );
}, '' );
return $users_info;
}
add_shortcode( 'user_info', 'user_info_shortcode' );Square root
Use the following shortcode to calculate the square root of a given number.
Usage:
[square_root number=9] -- displays 3 on the page.
[square_root number=[100]] -- in a View, displays the square root of the value in field with id 100.
function frm_square_root( $atts ) {
$a = shortcode_atts( array(
'number' => '1',
), $atts );
if ( ! is_numeric( $a['number'] ) || $a['number'] < 0 ) {
return '';
}
return sqrt( $a['number'] );
}
add_shortcode( 'square_root', 'frm_square_root' );Use Formidable shortcodes
With the following shortcode, special Formidable shortcodes like [get param], [date], and [user_role] in the enclosed content will be evaluated. This shortcode enables the use of these shortcodes on a normal WordPress page or post and in other non-Formidable contexts. Learn more about how to check which shortcodes work in each box.
Usage:
- [with-frm-shortcodes]Color is: [get param=color]. Date is [date].[/with-frm-shortcodes]
- [with-frm-shortcodes][frm-stats id=3871 type=count [if get param=color]3871=[get param=color][/if get]][/with-frm-shortcodes]
function with_frm_shortcodes_shortcode( $atts = [], $content = null, $tag = '' ) {
if ( ! is_null( $content ) ) {
if ( is_callable( array( 'FrmProFieldsHelper', 'replace_non_standard_formidable_shortcodes' ) ) ) {
FrmProFieldsHelper::replace_non_standard_formidable_shortcodes( array(), $content );
}
$content = do_shortcode( $content );
if ( is_callable( array( 'FrmAppHelper', 'kses' ) ) ) {
$content = FrmAppHelper::kses( $content, 'all' );
} else {
$content = wp_kses_post( $content );
}
}
return $content;
}
function with_frm_shortcodes_init() {
add_shortcode( 'with-frm-shortcodes', 'with_frm_shortcodes_shortcode' );
}
add_action( 'init', 'with_frm_shortcodes_init' );
add_filter( 'no_texturize_shortcodes', 'frm_shortcodes_to_exempt_from_wptexturize' );
function frm_shortcodes_to_exempt_from_wptexturize( $shortcodes ) {
$shortcodes[] = 'with-frm-shortcodes';
return $shortcodes;
}Remove empty shortcode params
You can remove shortcode parameters with empty values using the [frm-remove-empty] shortcode. This can be useful when you have a shortcode like [frm-graph] or [frm-stats] that has one or more field filters that get their values from [get param]. If the parameter in [get param] doesn't have a value, the field filter is removed. This shortcode is especially powerful in combination with the [with-frm-shortcodes] shortcode.
To use the frm-remove-empty shortcode:
- Create the normal shortcode exactly as you want it. For example: [frm-stats id=items type=total color="[get param=color]"].
- Put frm-remove-empty first and "source=" in front of the shortcode tag. Leave everything else the same. Final shortcode:
[frm-remove-empty source=frm-stats id=items type=total color="[get param=color]"]
On a page or post, put the shortcode inside [with-frm-shortcodes], so [get param] runs first. Without it, the page shows broken text, such as 0”]. Learn more about how to use Formidable shortcodes on a page.
Example using [with-frm-shortcodes]:
- [with-frm-shortcodes][frm-remove-empty source=frm-graph fields="4431" x_axis="3069" data_type="average" 3069_greater_than=[get param=startdate] 3069_less_than=[get param=enddate]][/with-frm-shortcodes]
function frm_remove_empty_shortcode( $atts = [], $content = null, $tag = '' ) {
if ( ! ( is_array( $atts ) ) || empty( $atts['source'] ) ){
return '';
}
$source = $atts['source'];
unset( $atts['source'] );
$atts_with_values = array_filter( $atts, function( $value ) {
return $value !== '';
});
$atts_string = '';
foreach ( $atts_with_values as $key=>$value ){
$atts_string .= " $key='$value'";
}
$shortcode_string = "[$source $atts_string]";
if ( ! is_null( $content ) ){
$shortcode_string .= " $content [/$source]";
}
$result = do_shortcode( $shortcode_string);
if ( is_callable( array( 'FrmAppHelper', 'kses' ) ) ) {
$result = FrmAppHelper::kses( $result, 'all' );
} else {
$result = wp_kses_post( $result );
}
return $result;
}
function frm_remove_empty_init() {
add_shortcode( 'frm-remove-empty', 'frm_remove_empty_shortcode' );
}
add_action( 'init', 'frm_remove_empty_init' );Conditional statement with OR condition
Use a conditional statement with OR condition in a View, message, or confirmation.
[compare_val val1="[x]" str="Yes" val2="[y]"] There is a match[/compare_val]
Add the code below to your theme functions.php or a new plugin to check if the user selected yes in either of the fields. Replace x and y with the ID of the fields you want to compare.
add_shortcode('compare_val', 'compare_multiple');
function compare_multiple($atts, $content=""){
extract(shortcode_atts(array('val1' => '', 'val2' => '', 'str' => ''), $atts));
if($val1 == $str || $val2 == $str){
return $content;
}
return '';
}Styles
Allow additional style rules
Use this code snippet to allow additional style rules that kses filtering deletes. This adds a list of style rules that will not be stripped when the style is used in a form submission, such as a rich text field.
add_filter('safe_style_css', 'add_style_rules');
function add_style_rules( $safe_style_css ) {
$safe_style_css[] = 'outline';
$safe_style_css[] = '-webkit-text-size-adjust';
$safe_style_css[] = '-ms-text-size-adjust';
$safe_style_css[] = '-moz-box-sizing';
$safe_style_css[] = '-webkit-box-sizing';
$safe_style_css[] = 'box-sizing';
return $safe_style_css;
}Cookies
Set a cookie for later use
This is commonly used when there is a value in the URL when your site is first reached. But if the form isn't submitted on that first page load, it's tricky to get those URL values into the form. The solution is to save the value to a cookie that will persist across pages.
add_action( 'init', 'set_url_cookie', 1 );
function set_url_cookie() {
$cookie_name = 'frm_url_value_' . COOKIEHASH; // change frm_url_value if you would like, but keep frm_ at the start
$value_name = 'utm_source';
if ( $_GET && isset( $_GET[ $value_name ] ) ) {
$expiration = 30000000;
$value = sanitize_text_field( wp_unslash( $_GET[ $value_name ] ) );
setcookie( $cookie_name, $value, time() + $expiration, COOKIEPATH, COOKIE_DOMAIN );
}
}Get a cookie value in a field
This example creates a shortcode you can use on a page or inside of a form field. The shortcode adds the site's cookie hash (COOKIEHASH) to the end of the name, so give the name without it. To show the value saved by the example above, include its underscore: [frm_referrer_cookie name="frm_url_value_"]. The name must start with frm_, so the shortcode can't show the WordPress login cookies. The value shows from the next page load on. On the first page, it is only in the URL.
add_shortcode( 'frm_referrer_cookie', 'frm_referrer_cookie' );
function frm_referrer_cookie( $atts ) {
$atts = shortcode_atts( array( 'name' => '' ), $atts );
$cookie_name = sanitize_text_field( $atts['name'] );
// Only cookies whose name starts with frm_, so the shortcode never shows a WordPress login cookie.
if ( 0 !== strpos( $cookie_name, 'frm_' ) ) {
return '';
}
$value = '';
$cookie_name = $cookie_name . COOKIEHASH;
if ( isset( $_COOKIE[ $cookie_name ] ) ) {
$value = sanitize_text_field( wp_unslash( $_COOKIE[ $cookie_name ] ) );
}
return esc_html( $value );
}


