wp_verify_nonce not working, whereas wp_create_nonce works

I am surprised why wp_verify_nonce not working. It’s showing undefined function error, my wordpress version is upto date. I am attaching my plugin code. Please help me

    add_shortcode('tw_safety_checklist_template','init_tw_safety_checklist');

    function init_tw_safety_checklist(){
        echo '<form method="post">
            <label>Name</label>
            <input type="hidden" name="tw_new_checklist_nonce" value="'.wp_create_nonce('tw_new_checklist_nonce').'"/>
            <input type="text" name="tw_name" />
            <input type="submit" name="submit" value="Submit"/>
        </form>';
    }

    if(isset($_POST['tw_new_checklist_nonce'])){
        tw_create_my_template();            
    } 

    function tw_create_my_template(){
        if(wp_verify_nonce($_POST['tw_new_checklist_nonce'],'tw-new-checklist-nonce'))
        {
            return 'Worked!';
        }
    }

Read more here: wp_verify_nonce not working, whereas wp_create_nonce works

Leave a Reply

Your email address will not be published. Required fields are marked *