hey guys i wanna call my function inside class A than call it inside class B within anonymous function how to do that ? here my sample code.


     class A extends Z{
        public function sampleFunction($post){
           // code here


     class B extends A{
       public __construct(){
    // add_action() and update_meta_box() is function from wordpress

       public function anotherClass(){
         $post = $_POST['test'];
    // here i dont know how to call it inside anonymous function


  • Solved link – user3073032 Dec 7 '13 at 6:36
  • Please do not duplicate questions across the network. – s_ha_dum Dec 7 '13 at 15:27

You need to specify which variables you want your closure to have access to, using the use part of the closure -- see manual.

add_action('save_post', function($id) use ($this, $post) {
    // ....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.