Title: Hook params not defined within PHP class
Last modified: August 20, 2017

---

# Hook params not defined within PHP class

 *  [caraffande](https://wordpress.org/support/users/caraffande/)
 * (@caraffande)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/hook-params-not-defined-within-php-class/)
 * Hi.
    Firstly thanks for this plugin. I’m developing a plugin for handling Paypal
   payments. In the main plugin’s file i have code like this:
 *     ```
       require 'classes/class.server.php';
       add_action('plugins_loaded', array('CRPP_IPN_Server_Class', 'init'));
       ```
   
 * and in the class.server.php I’ve set up code like this
 *     ```
           class CRPP_IPN_Server_Class extends WP_Plugin_Class
           {
   
               /**
                * Class' instance
                *
                * @access public
                * @var class instance
                */
               static $instance;
   
               /**
                * Init()
                * 
                * Class' instance initialization
                *
                * @access public 
                * @return instance
                * @author Raffaele Candeliere
                */
               static function init()
               {
                   is_null( self::$instance ) AND self::$instance = new self;
   
                   return self::$instance;
               }
   
               /**
                * __construct()
                *
                * Class' constructor
                *
                * @access public
                * @return void
                * @author Raffaele Candeliere
                */
               function __construct()
               {
                   /*
                    .
                    .
                    .
                    */
                   add_action( 'paypal_ipn_for_wordpress_payment_status_completed', array($this, 'ipn_payment_status_confirmed_handler'), 10, 1);
               }
   
               public function ipn_payment_status_confirmed_handler($posted) {
                   error_log(var_export($posted, true));
               }
       ```
   
 * Well, the problem is that if I define the hook like this, the $posted parameter
   doesn’t get populated. I do receive the notification but the $posted var is empty.
   
   Viceversa, if i hook into your plugin directly in my main’s plugin file, like
   this:
 *     ```
       add_action('plugins_loaded', 'crpp_init');
   
       function crpp_init() {
           add_action( 'paypal_ipn_for_wordpress_payment_status_completed', 'crpp_ipn_payment_satus_confirmed', 10, 1);
       }
   
       function crpp_ipn_payment_satus_confirmed($posted) {
           error_log(var_export($posted, true));
       }
       ```
   
 * then the $posted param is populated!
    I’d like to stick with my (standardized)
   programming pattern where i confine each functional block of code in the relevant
   class. What am I doing wrong in using/registering, calling your hook? Thanks
    -  This topic was modified 8 years, 9 months ago by [caraffande](https://wordpress.org/support/users/caraffande/).

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

 *  Plugin Contributor [angelleye](https://wordpress.org/support/users/angelleye/)
 * (@angelleye)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/hook-params-not-defined-within-php-class/#post-9425340)
 * I’d have to get our lead coder involved to know for sure, and I can’t pull him
   off his current projects for things like this unless they are [paid projects](https://www.angelleye.com/product/paypal-help/),
   unfortunately. I can try to help think it through with you, though.
 * My first thought would have something to do with $_POST not getting loaded as
   expected when run through your class for some reason. $posted is basically just
   $_POST with a couple of extra value pairs added. Can you check $_POST directly
   to see if it’s empty, too, inside your class? If you’re getting the log file 
   then the hook is triggering, so we just need to figure out where that data is
   getting lost..??
 * Maybe that doesn’t help you at all, but hopefully it’ll lead you in the right
   direction. This seems like something you might be able to get answered more quickly
   on StackOverflow in a general WordPress/WooCommerce tag.
 * I can try to have one of my guys take a quick look a little later, but it can
   be tough to pull them away.
 *  Thread Starter [caraffande](https://wordpress.org/support/users/caraffande/)
 * (@caraffande)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/hook-params-not-defined-within-php-class/#post-9426495)
 * Thank you very much for your detailed answer.
    I’ve followed your hint. I’ve 
   error_log’d the $_POST superglobal. You’re right. It’s empty. In any case thank
   you for your effort. At the moment, I’ll go the “main’s plugin file” way, hoping
   to have some other hint from you and/or the community in the future.

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

The topic ‘Hook params not defined within PHP class’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/paypal-ipn_b2a7a0.svg)
 * [PayPal IPN for WordPress](https://wordpress.org/plugins/paypal-ipn/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/paypal-ipn/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/paypal-ipn/)
 * [Active Topics](https://wordpress.org/support/plugin/paypal-ipn/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/paypal-ipn/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/paypal-ipn/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [caraffande](https://wordpress.org/support/users/caraffande/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/hook-params-not-defined-within-php-class/#post-9426495)
 * Status: not resolved