• Resolved verdut

    (@verdut)


    I have some polls created using forminator. What i need is when the submit button is pressed on a poll to trigger an action that prints the users choice from the form.

    I managed to get the form id when the submit button is pressed using forminator_poll_after_handle_submit hook, but i dont know how to get the form data and the user choice from here. Any help would be much appreciated. Thank you!

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @verdut

    I hope you are doing good today.

    I pinged our Forminator & SLS Team to review your query. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Hi again @verdut

    You can use the “forminator_poll_submit_response” filter to get form response and form id. Example:

    add_filter( 'forminator_poll_submit_response', function( $response, $form_id ) {
    	return $response;
    }, 10, 2 );

    Kind Regards,
    Kris

    Thread Starter verdut

    (@verdut)

    Hello. Thank you for the answer. But I’m having difficulties. In the $response variable as I could see there’s a message field that tells me if the vote has been saved or not, a notice and a success values.

    I need to get the answer that the user voted for. If let’s say the poll has 2 possible answers, Answer A and Answer B, when the user press Answer A, I need to get from the filter or the action, Answer A. Maybe I don’t know how to read the $response variable properly.

    Also, I figured out I have another question. I hope you can answer it here too. Is there also any filter or action that triggers when a poll is published in the wp admin area and also that gives the data of the poll created ? Like the title of the form and the answer options ?

    Thread Starter verdut

    (@verdut)

    Slight edit. When the user submits Answer A.(not on press, as mentioned above)

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @verdut

    Can you try this alternative?

    <?php
    
    add_filter( 'forminator_polls_submit_field_data', function( $field_data_array, $form_id ) {
    
    	return $field_data_array;
    
    }, 10, 2);

    https://monosnap.com/file/BZ3tPtoVirHo7Yd5hcAhRdnLJ3eR0E

    The first item in the array is the alternative voted.

    Best Regards
    Patrick Freitas

    Thread Starter verdut

    (@verdut)

    Thank you very much. It works.

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

The topic ‘Hook action on submit poll and get submitted data’ is closed to new replies.