Title: Extending 3rd party plugin class
Last modified: August 30, 2016

---

# Extending 3rd party plugin class

 *  [rkoziol7](https://wordpress.org/support/users/rkoziol7/)
 * (@rkoziol7)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/extending-3rd-party-plugin-class/)
 * Hello,
 * How to extend a 3rd party plugin class with a snippet or in functions.php of 
   my theme? The original class in plugin file I would like to extend looks like
   this:
 *     ```
       global $newsletter;
   
       class Newsletter extends NewsletterModule {
         static function instance() {
           if (self::$instance == null) {
               self::$instance = new Newsletter();
           }
           return self::$instance;
         }
         function __construct() {
           add_action('newsletter', array($this, 'hook_newsletter'), 1);
         }
         function hook_newsletter() {
           $this->logger->debug('hook_newsletter> Start');
           ...
         }
       }
   
       $newsletter = Newsletter::instance();
       ```
   
 * My class in functions.php in my theme looks like this:
 *     ```
       global $newsletter;
   
       class MyNewsletter extends Newsletter {
         static function instance() {
           if (self::$instance == null) {
             self::$instance = new MyNewsletter();
           }
           return self::$instance;
         }
         function __construct() {
           parent::__construct();
           $this->logger->debug('my hook_newsletter init');
           remove_action( 'newsletter', array( 'Newsletter', 'hook_newsletter' ) );
           add_action( 'newsletter', array( $this, 'hook_newsletter' ), 20 );
         }
   
         function hook_newsletter() {
           $this->logger->debug('my hook_newsletter> Start');
         }
       }
   
       $newsletter = MyNewsletter::instance();
       ```
   
 * However when the action ‘newsletter’ is being invoked the original class function
   is used. What I am doing wrong?
 * Best regards,
    Rob

The topic ‘Extending 3rd party plugin class’ is closed to new replies.

## Tags

 * [class](https://wordpress.org/support/topic-tag/class/)
 * [extend](https://wordpress.org/support/topic-tag/extend/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [rkoziol7](https://wordpress.org/support/users/rkoziol7/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/extending-3rd-party-plugin-class/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
