• Resolved ternion

    (@ternion)


    I’m looking at creating an addon for a client who wants to use your quiz plugin.

    Is there a hook to tell when a user has submitted a quiz that I can use to then go process information about the quiz?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey @ternion

    Thank you for choosing to use this plugin. There are not any hooks (though I should add them) but there are a lot of filters. There are filters at every step of the process after a user clicks submit. For example, this one after the admin email is sent: https://github.com/fpcorso/quiz_master_next/blob/master/php/class-qmn-quiz-manager.php#L589

    You can find any of those filters and whip up a function like this:

    
    function my_crazy_function( $content, $options, $results ) {
    // Do your processing here
    return $content;
    }
    

    The $options are the settings for the quiz. The $results is an array that includes all of the different results. You can see an example of the contents in the $results array over in the template-variables file here: https://github.com/fpcorso/quiz_master_next/blob/master/php/template-variables.php#L15

    However, that is not all that is in the array so I would suggest checking out a var_dump($results).

    At some point in the near future, I will get started on the developer documentation to make this easier 🙂

    Thread Starter ternion

    (@ternion)

    Thanks for getting back to me.

    I was digging around and found the filters. I was looking at the qmn_end_results filter.

    Would that be a good filter to use for processing after a survey is submitted?

    (I just to do some additional processing after the user submits the survey).

    Hey @ternion

    Most of the filters towards the end of that function are all passed the exact same variables as nothing changes them in the email functions.

    However, the qmn_end_results filter is the one I use with many of the addons as it is the only one called after the results are stored in the database which would allow me to update the results in the database if I wanted to.

    Thread Starter ternion

    (@ternion)

    Great thanks. I’ll use that one. Thanks again for the help.

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

The topic ‘Quiz Submit Hook’ is closed to new replies.