Title: getSubscribers() function does not work anymore?
Last modified: February 27, 2025

---

# getSubscribers() function does not work anymore?

 *  Resolved [wp_user1](https://wordpress.org/support/users/wp_user1/)
 * (@wp_user1)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/)
 * After updating MailPoet we got an error – what should we do here?
 * MailPoet 5.7.1/5.8.0
 * Here is the source code:
 *     ```wp-block-code
       if (class_exists(\MailPoet\API\API::class)) {$mailpoet_api = \MailPoet\API\API::MP('v1');}try {$fil=array('status'=>'subscribed','listId'=>$listid);$subscribers = $mailpoet_api->getSubscribers($fil,500);} catch (\Exception $e) {echo 'error';}
       ```
   

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

 *  Plugin Support [Kel C. a11n](https://wordpress.org/support/users/kellymetal/)
 * (@kellymetal)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18340792)
 * Hi there [@wp_user1](https://wordpress.org/support/users/wp_user1/),
 * What is the specific error message you are receiving?
 * I just tested on my site with the latest version 5.8.0 of the MailPoet plugin
   with the following snippet, and it wrote my list of subscribed subscribers to
   the log:
 *     ```wp-block-code
       function kel_test_footer_action() {    if (class_exists(\MailPoet\API\API::class)) {        try {            $mailpoet_api = \MailPoet\API\API::MP('v1');                        $fil = array(                'status' => 'subscribed',                'listId' => '1'            );            $subscribers = $mailpoet_api->getSubscribers($fil, 500);            error_log(print_r($subscribers, true));        } catch (\Exception $e) {            // Log the actual error        }    }}add_action( 'wp_footer', 'kel_test_footer_action');
       ```
   
 *  Thread Starter [wp_user1](https://wordpress.org/support/users/wp_user1/)
 * (@wp_user1)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18357097)
 * I get this error message:
 *     ```wp-block-code
       Fatal error: Uncaught Error: Call to a member function getSubscribers() on null in /var/www/html/wp-content/themes/xxx/functions.php:3504
       ```
   
 * Here is the code:
 *     ```wp-block-code
       if (class_exists(\MailPoet\API\API::class)) {
         $mailpoet_api = \MailPoet\API\API::MP('v1');
       }
         try {
           $get_subscribers = $mailpoet_api->getSubscribers(array('listId'=>3), 999);
         } catch (\Exception $e) {
   
         }
       ```
   
 *  Plugin Author [Ján Mikláš](https://wordpress.org/support/users/neosinner/)
 * (@neosinner)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18357259)
 * [@wp_user1](https://wordpress.org/support/users/wp_user1/) in your code, the 
   whole `try/catch` code needs to be inside the `if`. As you have it, when the 
   MailPoet API class doesn’t exist, you’ll still call the API, which results in
   the error you see.
 * So it should be like this:
 *     ```wp-block-code
       if (class_exists(\MailPoet\API\API::class)) {  $mailpoet_api = \MailPoet\API\API::MP('v1');  try {    $get_subscribers = $mailpoet_api->getSubscribers(array('listId'=>3), 999);  } catch (\Exception $e) {  }}
       ```
   
 * This will prevent the error from happening when the MailPoet API doesn’t exist.
 *  Plugin Author [Ján Mikláš](https://wordpress.org/support/users/neosinner/)
 * (@neosinner)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18357264)
 * [@wp_user1](https://wordpress.org/support/users/wp_user1/) one other thing. At
   the time, you are calling this code, the MailPoet is very likely not yet loaded,
   so the MailPoet API won’t work. You need to ensure, that MailPoet plugin is loaded
   before you try to call the API.
 *  Thread Starter [wp_user1](https://wordpress.org/support/users/wp_user1/)
 * (@wp_user1)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18357287)
 * Hm but Mailpoet is installed and active.. We did not change the code, but it 
   stopped working after upgrading Mailpoet.
 *  Thread Starter [wp_user1](https://wordpress.org/support/users/wp_user1/)
 * (@wp_user1)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18357298)
 * Could it be that Mailpoet stops working completely only because WooCommerce is
   not the newest version? 😮
 *  Plugin Author [Ján Mikláš](https://wordpress.org/support/users/neosinner/)
 * (@neosinner)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18357335)
 * > Could it be that Mailpoet stops working completely only because WooCommerce
   > is not the newest version? 😮
 * MailPoet supports the latest and the previous WooCommerce version (so at the 
   moment, 9.6.2 and 9.7.1) so if you have an older version, then yes, MailPoet 
   will disable itself, and you should see this notice on your admin pages:
 * > MailPoet plugin requires WooCommerce version 9.6.2 or newer. Please update 
   > your WooCommerce plugin version…
 *  Thread Starter [wp_user1](https://wordpress.org/support/users/wp_user1/)
 * (@wp_user1)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18357338)
 * okay this is really weird. We saw the Message but never expected that Mailpoet
   completely stops working then… Good to know :/
 *  Plugin Support [Gui A. a11n](https://wordpress.org/support/users/guicmazeredo/)
 * (@guicmazeredo)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18365769)
 * Yes. Please have that in mind from now on and you shouldn’t have issues. If you
   do, let us know. For now, I’m marking this thread as `resolved`.

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

The topic ‘getSubscribers() function does not work anymore?’ is closed to new replies.

 * ![](https://ps.w.org/mailpoet/assets/icon-256x256.png?rev=3284564)
 * [MailPoet - Newsletters, Email Marketing, and Automation](https://wordpress.org/plugins/mailpoet/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailpoet/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailpoet/)
 * [Active Topics](https://wordpress.org/support/plugin/mailpoet/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailpoet/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailpoet/reviews/)

 * 9 replies
 * 4 participants
 * Last reply from: [Gui A. a11n](https://wordpress.org/support/users/guicmazeredo/)
 * Last activity: [1 year, 2 months ago](https://wordpress.org/support/topic/getsubscribers-function-does-not-work-anymore-2/#post-18365769)
 * Status: resolved