[e-Newsletter Plugin] Shortcode to display subscriber count

All of the other WordPress Newsletter plugins (Mailster, Mailpoet, MailChimp, etc) have the option to display a subscriber count anywhere via a shortcode?

How can I do this with the eNewsletter plugin?

  • Konstantinos Xenos

    Hi Glenton !

    You can add this code snippet on your themes functions.php ( preferably the child themes ) and it will create a shortcode that returns the subscribers count. You can use the [enl-members-count] shortcode after you've added the code anywhere in the front-end.

    add_shortcode( 'enl-members-count', 'count_newsletter_members' );
    function count_newsletter_members() {
    	$count = 'Could not find E-Newsletter plugin';
    
    	if ( class_exists( 'Email_Newsletter_functions' ) ) {
    		global $wpdb;
    		$count = $wpdb->get_var( "SELECT Count(member_id) FROM {$wpdb->prefix}enewsletter_members WHERE unsubscribe_code != ''" );
    		return $count;
    	}
    
    	return $count;
    }

    Tell me if you need any further help or customization with this !

    Regards,
    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.