issue with the frm_after_create_entry hook

By: Walter Scheer | Asked: 03/15/2024
ForumsCategory: Code Helpissue with the frm_after_create_entry hook
Walter Scheer asked 9 months ago
field is updating in the back-end however if I use [frm-field-value field_id=73 entry="229"] --> it shows the old value... Never the updated one... So it seems it is not really updating it...   Below the function I have: add_action('frm_after_create_entry', 'frm_update_entry_answer1', 30, 2);
function frm_update_entry_answer1($entry_id, $form_id){
if ( $form_id !== 19 ) { //Change 997 to the ID of your update form
return;
} $entry_id = $_POST['item_meta'][105]; //change 9353 to the ID of the field in your update form that has the entry id
$field_id = 73; // change 9352 to the ID of the field in your main form that's to be updated
$new_value = approved; // change 'Approved' to the value you want to set the field in your main form $added = FrmEntryMeta::add_entry_meta( $entry_id, $field_id, null, $new_value );
if ( ! $added ) {
FrmEntryMeta::update_entry_meta( $entry_id, $field_id, null, $new_value );
}
}
1 Answers
Rob LeVineRob LeVine answered 9 months ago
I suggest putting some debug (error_log) statements in there to see what values are what at what point. The statement "$new_value = approved;" is problematic because "approved" doesn't have quotes around it. I'm guessing the add/update commands are failing.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right