ap_subscribers_count( string $event = '', integer $ref_id )

Description #

Get a subscribers count of a reference by specific event or without it.

Parameters #

  • $event
    string (Optional) Event type. Default value: ''
  • $ref_id
    integer (Required) Reference identifier id.

Changelog #

VersionDescription
4.1.5Introduced.

Source #

File: includes/subscribers.php

function ap_subscribers_count( $event = '', $ref_id = 0 ) {
	global $wpdb;

	$ref_query = '';

	if ( $ref_id > 0 ) {
		$ref_query = $wpdb->prepare( ' AND subs_ref_id = %d', $ref_id );
	}

	$event_query = '';

	if ( ! empty( $event ) ) {
		$event_query = $wpdb->prepare( ' AND subs_event = %s', $event );
	}

	$results = $wpdb->get_var( "SELECT count(*) FROM {$wpdb->ap_subscribers} WHERE 1=1 {$event_query} {$ref_query}" ); //phpcs:ignore WordPress.DB

	return $results;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment