Home Forums Newsletter Plugin Support displaying the count of subscribers on a website

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #17562
    Anonymous
    Inactive

    Hi,

    How should I go about displaying the amount of people that have subscribed the newsletter on a website?

    -Ville

    #17569
    Stefano
    Keymaster

    There is no such count, actually, you should execute a query to get it.

    #18263
    nofski
    Participant

    I’d be quite keen to get this figure on my website.

    Can you tell me what are the database table names we would be to execute this query.
    I have never done this before but always willing to dive into this type of stuff.

    Thanks

    mark

    #18275
    Stefano
    Keymaster

    wp_newsletter. wp_ can be different in your blog since it’s the configured table prefix for your installation.

    #278266
    MacStainless
    Participant

    For anyone looking for this, it took me a while to figure out. Why this is not offered as a simple API call is weird. However, you can do this with the following PHP query:


    $get = $wpdb->get_results(" SELECT * FROM ".$wpdb->prefix."newsletter WHERE status='C' ");
    echo count ($get);

    This queries the Newsletter database and only returns Confirmed subscribers. Then the count line gives you the total array size.

    Use a wordpress plugin like XYZ PHP Code to convert that PHP into a usable shortcode. Once you have that done, use the shortcode anywhere you want within your WP site.

    #278269
    Stefano
    Keymaster

    Hi, if you have many subscriber that query will run in a out of memory. Use this:
    $count = $wpdb->get_var(” SELECT count(*) FROM “.$wpdb->prefix.”newsletter WHERE status=’C’ “);

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
×