add_action, object property not accessible
-
Hi,
I’m probably missing something but cant figure out. Sample code does not work as i expected.In constructor, i change object property but when i dump it returns false. I havent dig into add_action but i assume it calls call_user_func so it should pass (?) already created object (with all assigned properties) even if not, i mean if it creates another instance, it should also go through constructor and assign ‘aaa’ value to $test.
To clearify, i want to get ‘aaa’ value from $test property while in testing method.
Thanks.
class trkr_test { private $test = false; public function __construct() { $this->test = 'aaa'; add_action( 'bp_setup_nav', array($this, 'testing'), 99 ); } public function testing() { var_dump($this); // returns object with all methods and properties but $test returns false not aaa } } function trkr_load_test() { $trkr_test = new trkr_test(); } add_action( 'plugins_loaded', 'trkr_load_test', 999 );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘add_action, object property not accessible’ is closed to new replies.