Docs & Support

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

frm_entry_meta_write_failed

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 third-party development.

Use the frm_entry_meta_write_failed action to run code when Formidable can't add, update, or delete a single field value of an entry in the database. It runs in place of frm_after_entry_meta_change. The saved value stays as it was.

Use it to log the failure, alert someone, or clean up work you started in frm_before_entry_meta_change.

Requirements

  • Formidable Forms 7.0 or later. The hook is part of Formidable Forms Lite.

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

When it fires

The action runs once per field value, when one of these writes fails:

  • Add: a new field value can't be inserted.
  • Update: an existing field value can't be changed to a new value. Saving the same value again isn't a failure.
  • Delete: a single field value can't be removed.

It doesn't run for values removed when an entry is edited. Those removals always run frm_after_entry_meta_change.

Usage

add_action( 'frm_entry_meta_write_failed', 'my_function_name', 10, 2 );

Parameters

  • $entry_id (int): The ID of the entry the value belongs to.
  • $field_id (int): The ID of the field whose value couldn't be saved.

Examples

Learn where to put the code when adding a custom PHP function to your site.

Log failed writes

This example writes the entry ID, field ID, and database error to the PHP error log. WordPress keeps the error from the last failed query in $wpdb->last_error.

add_action( 'frm_entry_meta_write_failed', 'my_frm_log_failed_write', 10, 2 );
function my_frm_log_failed_write( $entry_id, $field_id ) {
	global $wpdb;
	error_log( sprintf( 'Formidable could not save field %d for entry %d: %s', $field_id, $entry_id, $wpdb->last_error ) );
}

Forget a saved old value after a failed write

This example goes with the frm_before_entry_meta_change example. That example saves the old value of a field in $my_frm_old_values. This one removes the saved value when the write fails.

add_action( 'frm_entry_meta_write_failed', 'my_frm_forget_old_value', 10, 2 );
function my_frm_forget_old_value( $entry_id, $field_id ) {
	global $my_frm_old_values;
	unset( $my_frm_old_values[ $entry_id . '_' . $field_id ] );
}

Limitations

  • The hook runs only for values saved through Formidable's entry value functions. Deleting a whole entry, deleting a field, or deleting all entries of a form doesn't fire it.
  • This action runs your code and leaves the entry as it is. When a value can't be saved during a submission, the rest of the entry is still saved.
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 © 2026 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Don't forget your purchase!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms