/**
  * Callback when a membership earned
  *
  * @param WC_Memberships_Membership_Plan $membership_plan membership plan
  * @param array $args
  */
 public function membership_earned($membership_plan, $args)
 {
     $prefs = $this->prefs;
     $membership_plan_slug = $this->sanitize_slug($membership_plan->get_slug());
     $user_id = $args['user_id'];
     // Check if user is excluded (required)
     if ($this->core->exclude_user($user_id) === true) {
         return;
     }
     // Award points for any membership plan
     // Make sure we award points other then zero
     if (!empty($this->prefs['any']['creds']) && !$this->prefs['any']['creds'] == 0) {
         // Check limit
         if (!$this->over_hook_limit('any', 'mycred_woocommerce_memberships', $user_id)) {
             $this->core->add_creds('mycred_woocommerce_memberships', $user_id, $prefs['any']['creds'], $prefs['any']['log'], $membership_plan->get_id(), array('ref_type' => 'wc_membership_plan'), $this->mycred_type);
         }
     }
     // Award points for specific membership plan
     // Make sure we award points other then zero
     if (!empty($this->prefs[$membership_plan_slug]['creds']) && !$this->prefs[$membership_plan_slug]['creds'] == 0) {
         // Check limit
         if (!$this->over_hook_limit($membership_plan_slug, 'mycred_woocommerce_memberships_plan_' . $membership_plan_slug, $user_id)) {
             $this->core->add_creds('mycred_woocommerce_memberships_plan_' . $membership_plan_slug, $user_id, $prefs[$membership_plan_slug]['creds'], $prefs[$membership_plan_slug]['log'], $membership_plan->get_id(), array('ref_type' => 'wc_membership_plan'), $this->mycred_type);
         }
     }
 }