Why does 'modify_my_post' hook never fire when I save a Form?

By: Sam Z | Asked: 07/03/2022
ForumsCategory: Code HelpWhy does 'modify_my_post' hook never fire when I save a Form?
Sam Z asked 2 years ago

Hello, I'm attempting to use Formidable's API hooks to add custom functionality. Alot of the hooks I try to use never fire. Can you let me know what I might be doing wrong here? 

An example; I've enabled Formidable Lite and Formidable Pro and entered our License key. In our theme's functions.php I've put the following code:

function modify_my_post( $post, $args ) {
     error_log( 'frm_new_post FIRED' );
     return $post;
add_filter( 'frm_new_post', 'modify_my_post', 10, 2 );

Then I go to add and save a new Formidible form on this page mywebsite.com/wp-admin/admin.php?page=formidable&frm_action=edit&id=139.
My debug.log file never shows the hook executed. I'm finding that many of Formidable's hooks are not firing. For example, check_user_edit_form, frm_pre_update_entry, frm_allow_delete.   

Can you please inform us why these hooks do not fire please

1 Answers
Victor Font answered 2 years ago
frm_new_post is used to edit a post before it is created when the create post add-on is activated to create a CPT/post/page from your Formidable entry. This is a Pro filter that fires at line 156 in /formidable-pro/classes/models/FrmProPost.php check_user_edit_form is not a Formidable filter. frm_user_can_edit is the filter and forces a form to be editable regardless of a user's login status. This is a Pro filter that fires at line 94 in /formidable-pro/classes/helpers/FrmProEntriesHelper.php. frm_pre_update_entry fires before a form entry is updated while editing the record. This filter is fires in multiple places in both Formidable forms and Formidable Pro. You can find the source code at line 939 in /formidable/classes/models/FrmEntry.php. In Pro, this filter behaves differently. The is no corresponding apply_filters in Pro. In Pro, this filter processes data through Pro functions. frm_allow_delete can customize when an entry can be deleted. The Formidable Knowledge base has no further details about using this filter, so you'd have to examine Formidable's source code to understand it's function. You can find the source code for this filter at line 238 in /formidable-pro/classes/helpers/FrmProEntriesHelper.php. All of these filters fire.

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