Skip to content

Instantly share code, notes, and snippets.

@unaibamir
Created September 3, 2019 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unaibamir/9b090d4b1190f8bd532e755bb4568132 to your computer and use it in GitHub Desktop.
Save unaibamir/9b090d4b1190f8bd532e755bb4568132 to your computer and use it in GitHub Desktop.
<?php
/**
* Shortcode get course total users number
*
* @since 2.1.0
*
* @param array $atts shortcode attributes
* @return string course total users number
*/
function wn_course_access_list($atts) {
$atts = shortcode_atts( array(
'course_id' => 0,
), $atts, 'course_access_list' );
if( empty($atts["course_id"]) || $atts["course_id"] == 0 || FALSE === get_post_status( $atts["course_id"] )) {
return;
}
$course_users_query = learndash_get_users_for_course( $atts["course_id"], array(), false );
$user_ids = $course_users_query->get_results();
$total_users = count($user_ids);
return $total_users;
}
add_shortcode( "course_access_list", "wn_course_access_list" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment