Class gives non-object error when used in register_activation_hook
-
I’ve created a custom class for a new plugin, instantiated it, and have no trouble using it in or out of functions.
However, when I try to access a method of the instance within a function called by register_activation_hook(), I receive a PHP “Call to a member function on a non-object” error.
Yes, I am declaring the instance as a global within the function.
For example:
class myClass{ public function doStuff(){ return true; } } $myInstance = new myClass(); register_activation_hook(__FILE__,'do_things'); function doThings(){ global $myInstance; $test = $myInstance->doStuff(); //non-object error }
The above code SHOULD be valid, but returns a non-object error for doStuff when it’s function is run by register_activation_hook.
Ideas?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Class gives non-object error when used in register_activation_hook’ is closed to new replies.