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 !