• Resolved phloo

    (@phloo)


    There are a lot of hooks/filters but no documentation

    Current case: we have a single checkbox, which when not checked, should send a value in the mail. Without filter it’s just empty/missing.

    Trie the following code but not sure how to view content/data/fields to modify them.

    add_filter( 'forminator_replace_custom_form_data', 'replace_form_data', 10, 2 );
    
    function replace_form_data($content, $data, $fields) {
            // do something here
    	return $content;
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @phloo,

    You can find API docs on our site here:
    https://premium.wpmudev.org/docs/wpmu-dev-plugins/forminator-api-docs/

    And some additional usage information on the blog post here:
    https://premium.wpmudev.org/blog/how-to-build-custom-forminator-add-ons-using-the-developer-api/

    Let me know if that helps with accomplishing your goal 🙂

    Cheers,
    Predrag

    Thread Starter phloo

    (@phloo)

    Thanks for the reply

    There is no informations about the question I posted.
    None of the API docs lists any information for the hook when a submission gets send via mail nor is there any code example for it.

    So no, doesnt really help.

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @phloo ,

    Please check our developer’s suggestion:

    Use different filter:

    /**
     * $data        - the post data
     * $custom_form - the form
     * $entry       - saved entry
     */
    add_filter( 'forminator_custom_form_mail_data', function( $data, $custom_form, $entry ){
    	return $data;
    }, 10, 3 );
    //source: forminator/library/modules/custom-forms/front/front-mail.php on line 123
    
    

    like that:

    /**
     * array $data        - the post data
     * object Forminator_Custom_Form_Model $custom_form - the form
     * object Forminator_Form_Entry_Model $entry       - saved entry
     */
    add_filter( 'forminator_custom_form_mail_data', function( $data, $custom_form, $entry ){
    	$checkbox_id = 'checkbox-1';
    	// if this checkbox is not checked
    	// @file_put_contents( ABSPATH .'/data.txt', "\n-------\n". print_r( $data, true ), FILE_APPEND );//use this to log the data to your root-site/data.txt file
    	if( ! isset( $data[ $checkbox_id ] ) ){
    		// do something if checkbox is not checked
    	}
    	return $data;
    }, 10, 3 );
    Thread Starter phloo

    (@phloo)

    Hi Kasia,

    thanks for the feedback and code example.

    This is helpful. But I still don’t understand how you can find such examples on your documentation pages, nor do I see anything like that on your dev’s provided links in the first answer. Even the search doesn’t find any infos about this filter, etc.

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @phloo

    I hope you are doing well!

    As Kasia has mentioned in a previous thread, the code was provided by our developer 🙂

    Please let us know if you will have any further questions.

    Kind regards,
    Nastia

    Thread Starter phloo

    (@phloo)

    Still testing, Nastia. But I guess we will be fine.

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

The topic ‘How to modify data for email notification?’ is closed to new replies.