• Resolved comeodore

    (@comeodore)


    How can i intergrate form with 2 google sheets tables i need to export same data to 2 tables

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter comeodore

    (@comeodore)

    And second question how can i find functional for “Send” (Submit button) i need to add to him some PHP code

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @comeodore

    I hope you are doing well.

    I’m afraid there is no way to create two Google sheets at this moment for a single form, you can check the Zapier integration, Forminator will connect to Zapier and Zapier to multiple other apps, and then on Zapier, you should be able to handle a more complex Google Sheets integration.

    Once that said, I’m also sending this ticket as a feature request to our developers to allow users to implement multiple sheets for a single form.

    For the second question, you can use the hook:

    add_action( 'forminator_custom_form_after_handle_submit', 'my_custom_function_doing_something_with_form_data', 10, 2 );
    
    function my_custom_function_doing_something_with_form_data( $form_id, $response ) {
    
    // in $form_id you got an ID of the form just submitted so you can use API do get data
    
    // and then to what you want/need with it
    
    }

    Let us know if you have any further question on this.
    Best Regards
    Patrick Freitas

    Thread Starter comeodore

    (@comeodore)

    @wpmudevsupport12 It is right? Cuz its didnt work and idk why
    add_action( ‘forminator_custom_form_after_handle_submit’, ‘funn’, 10, 2);
    function funn( $form_id, $response ) {
    $form_id = 38;
    $response = 1;
    echo “Hello”;
    }

    • This reply was modified 4 years, 2 months ago by comeodore.
    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @comeodore,

    The earlier one would trigger only when the form is submitted and the email is sent. To have it on click on the button you can use something like this:

    For simple non-pagination form:

    add_filter( 'forminator_render_button_markup', function( $html, $button ){
    		return $html;
    	}, 10, 2 );

    For a form with pagination you can use something like this:

    add_filter( ‘forminator_pagination_submit_markup’, function( $html ){
    //
    $html = ‘before button.’. $html;
    $html .= ‘after button’;
    return $html;
    } );

    Let me know if that works for you on your end.

    Thank you,
    Prathamesh Palve

    Thread Starter comeodore

    (@comeodore)

    @wpmudev-support7 I need to type this in function.php? I need to do something with word doc after sumbit form. And its doesnt matters when this is triggered, submit + sent email its good but trigger didnt work, i didnt see echo “Hello”

    • This reply was modified 4 years, 2 months ago by comeodore.
    • This reply was modified 4 years, 2 months ago by comeodore.
    Thread Starter comeodore

    (@comeodore)

    And what i must do to take something info from form to PHP argument?

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @comeodore,

    You can either add that at the end of your child theme function file or add it as a mu-plugin. Here is how you can add it as a mu-plugin:

    https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins

    If you are using as am mu plugin, you can use the following code to add it as a mu-plugin:

    <?php
    add_filter( 'forminator_render_button_markup', function( $html, $button ){
    		return $html;
    	}, 10, 2 );

    If you would be adding it in the child theme function file, here is how you can create a child theme:
    https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

    We recommend you to make a child theme if you want to add it in the theme function file and add the code in the child theme function file as that ould not affect your site if you update your main theme any time.

    Thank you,
    Prathamesh Palve

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @comeodore,

    I gave that a second thought too and here is what I thought:

    And second question how can i find functional for “Send” (Submit button) i need to add to him some PHP code

    I am not a bit clear here and need more clarification here.

    But when you said:

    I need to type this in function.php? I need to do something with word doc after sumbit form.

    Seems like you are looking to handle the data after submitting the form.

    Also, when you said:

    And its doesnt matters when this is triggered, submit + sent email its good but trigger didnt work, i didnt see echo “Hello”

    You can’t show the Hello while submitting the form. If you enable submit the form via page reload (not using ajax submit), you can show the Hello by exit after echo.

    add_action( 'forminator_custom_form_after_handle_submit', 'funn', 10, 2);
    function funn( $form_id, $response ) {
    	$form_id = 38;
    	$response = 1;
    	echo "Hello";
    	exit;
    }

    This above would give you an idea on why previously it would not have worked. Also using log data is more better than echo.

    Example:

    add_action( 'forminator_custom_form_after_handle_submit', 'funn', 10, 2);
    function funn( $form_id, $response ) {
    	// log data to data1.txt file
    	@file_put_contents( dirname(__FILE__).'/data1.txt', "\n-------\n form_id:". $form_id, FILE_APPEND );
    	@file_put_contents( dirname(__FILE__).'/data1.txt', "\n-------\n response:". print_r( $response, true ), FILE_APPEND );
    }

    If you want to use the submitted data, you can use the following hook:

    add_action( 'forminator_custom_form_submit_before_set_fields', function( $entry, $form_id, $field_data_array  ){
    	// log data to data2.txt file
    	@file_put_contents( dirname(__FILE__).'/data2.txt', "\n-------\n form_id:". $form_id, FILE_APPEND );
    	@file_put_contents( dirname(__FILE__).'/data2.txt', "\n-------\n field_data_array:". print_r( $field_data_array, true ), FILE_APPEND );
    	// handle the php code with submited data
    	foreach( $field_data_array as $field ){
    		if( $field['name'] === 'text-1' ){
    			// do something with text 1 field
    		}
    	}
    }, 10, 3 );

    Please let me know if that helps you. Do let me know if you are looking on something else and I missed it.

    Thank you,
    Prathamesh Palve

    Thread Starter comeodore

    (@comeodore)

    @wpmudev-support7 Hello again, thanks for helping me

    I am not a bit clear here and need more clarification here.

    I would like to use the first name (text-1) and last name (text-2) in the doc file after submitting the response in the form (pressing the Submit button or after sending the mail, it does not matter), where they will replace two variables that are responsible for every (for example fill in data2.txt ‘text-1’ and ‘text-2’ fields)

    If you want to use the submitted data, you can use the following hook:

    When i use dirname(__FILE__).’/data2.txt’, i cant find this file by Search
    And i try another way with DIR and use this only for fill file but this is didnt work, but why? (File is empty after submit form)

    add_action( 'forminator_custom_form_submit_before_set_fields', function( $entry, $form_id, $field_data_array  ){
    	// log data to data2.txt file
    	@file_put_contents( 'public_html/jaxx.dr-weedy.care/data2.txt', "\n-------\n form_id:". $form_id, FILE_APPEND );
    	@file_put_contents( 'public_html/jaxx.dr-weedy.care/data2.txt', "\n-------\n field_data_array:". print_r( $field_data_array, true ), FILE_APPEND );
    }, 10, 3 );
    • This reply was modified 4 years, 2 months ago by comeodore.
    • This reply was modified 4 years, 2 months ago by comeodore.
    • This reply was modified 4 years, 2 months ago by comeodore.
    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @comeodore,

    I tried using the exact same snippet and that worked for me:

    add_action( 'forminator_custom_form_submit_before_set_fields', function( $entry, $form_id, $field_data_array  ){
    	// log data to data2.txt file
    	@file_put_contents( WP_CONTENT_DIR . '/data2.txt', "\n-------\n form_id:". $form_id, FILE_APPEND );
    	@file_put_contents( WP_CONTENT_DIR . '/data2.txt', "\n-------\n field_data_array:". print_r( $field_data_array, true ), FILE_APPEND );
    }, 10, 3 );

    The path you used is wrong: public_html/jaxx.dr-weedy.care/data2.txt
    If you use the exact snippet I used as of above, it should create the data2.txt file in the wp-content directory. Another reason for the snippet not working would be the current user permissions for PHP would not be correct. Please do check if the permissions are good.

    The WP_CONTENT_DIR is the path to the wp-content folder and file_put_contents is a standard PHP function.

    If that does not work, you can try running something simpler, for example, running file_put_contents in an init action to see if it works.

    Also for further references, you can use the forminator API to make the most out of the plugin resources. Here is the link to it:
    https://premium.wpmudev.org/docs/api-plugin-development/forminator-api-docs/#method-get_form_field

    Thank you,
    Prathamesh Palve

    Thread Starter comeodore

    (@comeodore)

    @wpmudev-support7 Thank you very much, i solve this. Have a good day.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Integration with 2 google sheets tables’ is closed to new replies.