Formidable Forms

The Most Advanced WordPress Forms Plugin and Form Builder

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

frm_pre_create_entry

Last Updated: April 27, 2018

Knowledge Base → Extend Formidable Forms → Formidable Hooks - for Developers → Entry Management → frm_pre_create_entry
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook can be used to manipulate the values in an entry prior to it’s creation.

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

Usage

add_filter('frm_pre_create_entry', 'adjust_my_field');
function adjust_my_field($values)

Parameters

  • $values (array)

Examples

Prepend a value

This example allows you to prepend a static message before the user's field entry. For example, if the user entered '1234' and you wanted the value to be saved as 'ss-001234', you could use the code below to accomplish this.

add_filter('frm_pre_create_entry', 'adjust_my_field');
function adjust_my_field($values){
  if ( $values['form_id'] == 5 ) { //change 5 to your form id
    $current_value = $values['item_meta'][25]; // change 25 to to id of your field
    if ( strpos( $current_value, 'ss-00' ) === false ) { // check if the value is already included
      $values['item_meta'][25] = 'ss-00' . $values['item_meta'][25];
    }
  }
  return $values;
}

Import file from URL

This can come in handy in a few different cases. First, when using the API, you can accept a file url, and import it onto your site. Second, if you would like to accept links to files that are already online, rather then requiring users to download and then upload an image.

This example uses two different fields: one for the file url, and one for the upload field. The value in the url field will be used to fill the upload field when possible.

add_filter('frm_pre_create_entry', 'frm_upload_from_url');
function frm_upload_from_url( $values ) {
  if ( $values['form_id'] == 5 ) { //change 5 to your form id
    $upload_field_id = 25; // replace 25 with the id of your upload field
    $url_field = 24; // replace 24 with the id of your url field
    $has_url = isset( $values['item_meta'][ $url_field ] ) && ! empty( $values['item_meta'][ $url_field ] );
    $has_upload = isset( $values['item_meta'][ $upload_field_id ] ) && ! empty( $values['item_meta'][ $upload_field_id ] );
    if ( $has_url && ! $has_upload ) {
      $_REQUEST['csv_files'] = 1;
      $field = FrmField::getOne( $upload_field_id );
      $values['item_meta'][ $upload_field_id ] = FrmProFileImport::import_attachment( $values['item_meta'][ $url_field ], $field );
    }
  }
  return $values;
}
  • Usage
  • Parameters
  • Examples
    • Prepend a value
    • Import file from URL
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