Created
September 3, 2019 16:14
-
-
Save unaibamir/9b090d4b1190f8bd532e755bb4568132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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