Title: Using Forminator API to prepopulate field
Last modified: November 15, 2023

---

# Using Forminator API to prepopulate field

 *  Resolved [jamminjames](https://wordpress.org/support/users/jamminjames/)
 * (@jamminjames)
 * [3 years ago](https://wordpress.org/support/topic/using-forminator-api-to-prepopulate-field/)
 * Regarding the Forminator API, I’m using the free version, and are trying to update
   a hidden field in a form via the API which would then be used to prepopulate 
   the behavior string, but no matter what I try, when it is submitted, the field
   does not show up in the behavior.
 * I want to redirect to a url using a variable, because the url changes. In behavior,
   I have:
 *     ```wp-block-code
       https://www.forwardto.com/{hidden-4}?type={radio-2}
       ```
   
 * The “{radio-2}” variable works fine, as it is entered on the form. However, the{
   hidden-4} field is the tricky one. It needs to be populated via a variable that
   is not in the field initially, and I can’t bring it in via a url parameter.
 * Using the API, I’m accessing the variable from some userdata (website url). That
   works fine. Then, I’ve tried these things to update the hidden form field:
 *     ```wp-block-code
       Forminator_API::update_form_fieldForminator_API::add_form_field
       ```
   
 * Looking at the form data with
 *     ```wp-block-code
       Forminator_API::get_form_fields_by_type( $form_id, 'hidden' ) 
       ```
   
 * …it looks like the data is being added to the field, but when the form is submitted,
   it doesn’t get recorded in the db, nor is it used by behavior.
 * I’ve also tried Forminator_API::update_form_entry, and that does get recorded
   in the db, but it apparently happens after the form submission, so it can’t get
   used in the form ‘behavior’.
 * How can this be accomplished? Any help would be appreciated.
    -  This topic was modified 3 years ago by [jamminjames](https://wordpress.org/support/users/jamminjames/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [Saurabh – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support7/)
 * (@wpmudev-support7)
 * [3 years ago](https://wordpress.org/support/topic/using-forminator-api-to-prepopulate-field/#post-16870334)
 * Hi [@jamminjames](https://wordpress.org/support/users/jamminjames/)
 * Hope you are doing fine.
 * You can try the following code snippet as an example to change the value of the
   hidden field. The code will be the following:
 *     ```wp-block-code
       add_filter( 'forminator_prepared_data', 'wpmudev_add_hidden_field_time', 10, 2 );
       function wpmudev_add_hidden_field_time( $prepared_data, $module_object ){
       	if ( $module_object->id != 6 ) {
       		return $prepared_data;
       	}
   
       	$prepared_data['hidden-1'] = $value_of_hidden_field;
   
       	return $prepared_data;
       }
   
       add_action( 'forminator_custom_form_submit_before_set_fields', 'wpmudev_change_hidden_field_date', 10, 3 );
       function wpmudev_change_hidden_field_date( $entry, $module_id, $field_data_array ) {
           $form_ids = array(6); //Please change the form ID
       	if ( !in_array( $module_id, $form_ids ) ) {
       		return;
       	}
   
           foreach ( $field_data_array as $key => $value ) {
               if ( strpos( $value['name'], 'hidden-1' ) !== false ) {
                   Forminator_CForm_Front_Action::$info['field_data_array'][$key]['value'] = $value_of_hidden_field;
               }
           }
   
       }
       ```
   
 * Remember to change the number “6” with your form id.
 * Let us know if this code helps. Feel free to reply if you have any additional
   questions or concerns.
 * Kind regards
 * Luis
 *  Thread Starter [jamminjames](https://wordpress.org/support/users/jamminjames/)
 * (@jamminjames)
 * [3 years ago](https://wordpress.org/support/topic/using-forminator-api-to-prepopulate-field/#post-16870488)
 * Thanks very much. I couldn’t find anything in the API documentation nor the plugin
   docs about hooks, other than the depreciated and changed ones it mentions. It
   only lists methods. Where is the action and filter hook info? It should be easier
   to find from this [API documentation](https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/).
    -  This reply was modified 3 years ago by [jamminjames](https://wordpress.org/support/users/jamminjames/).
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [3 years ago](https://wordpress.org/support/topic/using-forminator-api-to-prepopulate-field/#post-16871325)
 * Hi [@jamminjames](https://wordpress.org/support/users/jamminjames/)
 * You are right – hooks (both action and filter) currently have no public documentation
   similar to API methods, I’m afraid.
 * I’m not saying that it will never happen but for now I don’t think it’s going
   to happen soon. It isn’t due to any “secrets” (especially that the code can be
   checked directly) but mostly due to the fact that fully and clearly documenting
   all the hooks from all our plugins is a lot, lot of work (by this I mean a proper
   docs, other than just using automatically generate list of hooks) and it takes
   a lot of time to go through it and keep up to the changes.
 * So for now, you can always do a full-text search in the plugin for “do_action”
   and “apply_filter” strings and most of them will have at least a short explanation
   in code comment (or would be more or less self-explanatory).
 * I’m aware this may be inconvenient but please also remember that at any time 
   you are more than welcome to just ask us and we’ll be happy to help.
 * Best regards,
    Adam
 *  Thread Starter [jamminjames](https://wordpress.org/support/users/jamminjames/)
 * (@jamminjames)
 * [3 years ago](https://wordpress.org/support/topic/using-forminator-api-to-prepopulate-field/#post-16872693)
 * Okay, you’re saying search within the actual plugin files within \wp-content\
   plugins\forminator\ on our site, yes? Didn’t think of that.
 * I hope WPMU can document them at some point.
 * Thanks for all your help!
 *  Plugin Support [Jair – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport15/)
 * (@wpmudevsupport15)
 * [3 years ago](https://wordpress.org/support/topic/using-forminator-api-to-prepopulate-field/#post-16875301)
 * Hi [@jamminjames](https://wordpress.org/support/users/jamminjames/),
 * I hope you are doing well today!
 * > Okay, you’re saying search within the actual plugin files within \wp-content\
   > plugins\forminator\ on our site, yes? 
 * Yes, we are referring to text search within plugin files and we hope to have 
   a full documentation in the future when possible.
 * Kind regards,
   Zafer

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Using Forminator API to prepopulate field’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [update](https://wordpress.org/support/topic-tag/update/)

 * 5 replies
 * 5 participants
 * Last reply from: [Jair – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport15/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/using-forminator-api-to-prepopulate-field/#post-16875301)
 * Status: resolved