• This doing my head in. Here for 3 hours now trying to figure it out.

    I am getting this error when I post an update.

    Fatal error: Call to undefined function wp_verify_nonce()

    Here is my code which generates the nonce. (the unique nonce gets generated when I look at it in source)

    <input type="hidden" name="_ws250nonce" value="<?php echo wp_create_nonce('ws250updater') ?>" />
    <input type="hidden" name="ws250action" value="update"   />
    <input type="hidden" name="page" value="ws250-admin-layouts"   />

    Here is my code which (is supposed to) verifies the nonce.
    ` if (!wp_verify_nonce($nonce, ‘ws250updater’) ) die(‘Security check’); {
    }`

    I am running latest version of wordpress version 3.1.

    The error is saying I am trying to call an undefined function. The function wp_verify_nonce is it not supposed to be included in the wordpress core files?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Having the same problem.

    So far I have solved it by simply copy-pasting verify into my script and thus re-defining it.

    Here is the function:

    function wp_verify_nonce_X($nonce, $action = -1) {
            return true;
    		$user = wp_get_current_user();
    		$uid = (int) $user->id;
    
    		$i = wp_nonce_tick();
    
    		// Nonce generated 0-12 hours ago
    		if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
    			return 1;
    		// Nonce generated 12-24 hours ago
    		if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) == $nonce )
    			return 2;
    		// Invalid nonce
    		return false;
    	}

    It is originally located in /wp-includes/pluggable.php
    Will keep working on figuring out why this suddenly came up. Worked fine before I rolled into 3.1 yesterday.

    Until there is a better solution, just put:
    require_once(ABSPATH .'wp-includes/pluggable.php'); at the top of your plugin or whenever you need to call wp_verify.
    It is very strange, but it seems like the file is simply not being included. I will attempt to /bug it.

    Same error for me but solved by putting require_once(ABSPATH .’wp-includes/pluggable.php’); on the construct of my class. This is a strange behavior.

    emixiak

    (@emixiak)

    Same error for me. Using wordpress 3.1.2

    This problem mainly occurs when you call the function before it is loaded, So to avoid this error use ‘init’ or ‘wp_loaded’. These are the best hooks to process your post or get variables as far as I know. I got the same error and after diving into the core files I ended up using these hooks and everything went ok. WordPress Rocks !

    Thanks this helps me a lot

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

The topic ‘Fatal error: Call to undefined function wp_verify_nonce()’ is closed to new replies.