Title: Hook for additional checks before saving
Last modified: March 27, 2017

---

# Hook for additional checks before saving

 *  [mheiduk](https://wordpress.org/support/users/mheiduk/)
 * (@mheiduk)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/hook-for-additional-checks-before-saving/)
 * Hi,
 * I am trying to check if the mail already exists in the database for this form.
   If so, the form shouldn’t be saved and an error should be thrown.
 * At the moment I am using the hook ‘torro_response_saved’ for getting the form
   data in order to insert the user in an external newsletter database (if checkbox
   is checked). Is there any hook before the data gets saved? How can I throw an
   error and display it above the form?
 * Thanks!
 * Best,
    Marc

Viewing 1 replies (of 1 total)

 *  Plugin Author [Sven Wagener](https://wordpress.org/support/users/mahype/)
 * (@mahype)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/hook-for-additional-checks-before-saving/#post-8975446)
 * Hi Marc,
 * yes there is an actionhook for that. It is named ‘torro_element_type_validate_input’;
 * Just take a look here:
    [https://github.com/awsmug/torro-forms/blob/master/core/models/class-element-type.php#L103](https://github.com/awsmug/torro-forms/blob/master/core/models/class-element-type.php#L103)
 * Code example for additional check:
 *     ```
       function my_element_check( $input, $element ) {
           if( $element->id === YOURELEMENT_ID ) // Replace YOURELEMENT_ID
           {
               if( ! your_db_emailcheck( $input ) ){
                   return new new Torro_Error( 'email_exists_in_db', __( 'Your Email already exists in the database.', 'torro-forms' ) );
               }
               return $input;
           }
           return $input;
       }
       add_filter( 'torro_element_type_validate_input', 'my_element_check' );
       ```
   
 * I hope that helps you!
 * Greetings,
 * Sven

Viewing 1 replies (of 1 total)

The topic ‘Hook for additional checks before saving’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/torro-forms_a76868.svg)
 * [Torro Forms](https://wordpress.org/plugins/torro-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/torro-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/torro-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/torro-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/torro-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/torro-forms/reviews/)

## Tags

 * [before](https://wordpress.org/support/topic-tag/before/)
 * [form](https://wordpress.org/support/topic-tag/form/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [save](https://wordpress.org/support/topic-tag/save/)

 * 1 reply
 * 2 participants
 * Last reply from: [Sven Wagener](https://wordpress.org/support/users/mahype/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/hook-for-additional-checks-before-saving/#post-8975446)
 * Status: not resolved