LLMS_Analytics::get_total_users_all_time( $post_id,  $end_date )

Query user_postmeta for all users enrolled by course


Description Description


Return Return

([type]) [description]


Top ↑

Source Source

File: includes/class.llms.analytics.php

	public static function get_total_users_all_time( $post_id, $end_date ) {
		global $wpdb;

		//add 1 day to time to account for striptime
		$end_date = LLMS_Date::db_date( $end_date . '1 day' );

		$table_name = $wpdb->prefix . 'lifterlms_user_postmeta';
		$results = $wpdb->get_results(
			$wpdb->prepare(
				'SELECT
					p.user_id,
					p.post_id,
					MAX(IF(pa.meta_key = "_start_date", pa.updated_date, NULL)) AS enrolled_date,
					MAX(IF(pa.meta_key = "_status", pa.meta_value, NULL)) AS status,
					MAX(IF(pa.meta_key = "_is_complete", pa.updated_date, NULL)) AS completed_date
					from ' . $table_name . ' p
					left join ' . $table_name . ' pa on p.user_id = pa.user_id and p.post_id = pa.post_id
					where p.post_id = %s
					and p.updated_date <= %s
					group by p.user_id',
				$post_id, $end_date
			)
		);

		return $results;

	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.