Incorrect number of trails shown

Currently, I only have 1 trail, but the statistics show that I have six active trials. The others are no longer trails.
It also shows data for sites that have been deleted.

  • Uttam Kumar

    Hey Greg ,

    I hope you are doing well today and thank you for your question!

    I investigate to your site and could find that your multisite has bellow status

    Status = Blog IDs separated by commas

    Pro site active = 1,
    Pro site active trial = 17
    Expired = 2
    Expired with trial = 18 , 19 , 20

    So its showing 2 active Pro Sites ( 1 and 17 ) and 4 active trials ( 17 , 18 ,19 and 20 ).

    But I could see that deleted site statistics also shown in this list. I created a demo site and deleted it and now statistics show that it has 5 active trials. So I need to investigate more on my site so that I could call it a bug. It might take some more time to investigate it.

    I appreciate your patience and understanding

    Kind Regards,
    Uttam

  • Uttam Kumar

    Hello Greg ,

    Sorry for the delay in getting back to you.

    You can get the ID's of the sites that are on a trial that have not expired yet by following code.

    function get_trial_blog_list_fn() {
    
    	global $wpdb;
    	// Get all current site details
    	$site_details = get_sites();
    	// all active site ids
    	$site_ids = array();
    	if( !empty($site_details) ) {
    		foreach ( $site_details as $sd_key => $sd_row ) {
    			$site_ids[] = $sd_row->blog_id;
    		}
    	}
    
    	$trial_site_ids = $wpdb->get_col( $wpdb->prepare(
    		"SELECT blog_ID FROM {$wpdb->base_prefix}pro_sites WHERE expire > '" . time() . "' AND meta LIKE %s",
    		'%\"trialing\"%'
    	));
    
    	$org_trial_site = array_intersect( $trial_site_ids, $site_ids );
    
    	// here is original trial site that have not expired yet.
    	print_r( $org_trial_site );
    }

    Let me know if this will work for you.

    Kind Regards,
    Uttam