• Resolved lividunlined

    (@hazirahs)


    Hi,

    Is there a way to set a cookie to the submit button? I want to create a popup after user submitted their quiz if this is possible.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @hazirahs

    I need to discuss this with my development team. Hopefully, I will get back to you with the solution.

    Regards,
    Sumit

    Hi @hazirahs ,

    You can use below-given action hook which you can use to create a cookie after submitting a quiz.

    function add_submit_record( $results_array, $results_id, $qmn_quiz_options, $qmn_array_for_variables ) {
    //Your Code
    }
    add_action(‘qsm_quiz_submitted’, ‘add_submit_record’, 30, 4);

    Let me know if you need more help.

    Regards,
    Sumit

    Thread Starter lividunlined

    (@hazirahs)

    Hi @sumitsanadhya,

    I’ve tried for days and still was not able to setup the cookie. Sorry my knowledge on this is rather bad… Can you please check where I went wrong?

    function add_submit_record( $results_array, $results_id, $qmn_quiz_options, $qmn_array_for_variables ) {
    //Your Code
    $cookie_name = ‘qsm_submit’;
    $cookie_value = $results_id;
    setcookie($cookie_name, $cookie_value, time() + (86400 * 14), ‘/’);
    }
    add_action(‘qsm_quiz_submitted’, ‘add_submit_record’, 30, 4);

    Thank you

    Hi @hazirahs

    It seems that there is some issue with the inverted comma. I request you to please check below-given code.

    function add_submit_record( $results_array, $results_id, $qmn_quiz_options, $qmn_array_for_variables ) {
    
    //Your Code
    
    $cookie_name = 'qsm_submit';
    
    $cookie_value = $results_id;
    
    setcookie($cookie_name, $cookie_value, time() + (86400 * 14), '/');
    
    }
    
    add_action('qsm_quiz_submitted', 'add_submit_record', 99, 4);

    Regards,
    Sumit

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cookie for submit button’ is closed to new replies.