apply_filters( 'learndash_show_user_course_complete_options', boolean $show_options, int $user_id )
Filters the status of whether the course is completed for a user or not.
Description #
Parameters #
- $show_options
-
(boolean) Whether the course is completed or not.
- $user_id
-
(int) ID of the logged in user to check.
Source #
File: includes/ld-users.php
Examples #
Note: Extended code example below not guaranteed, you may need to consult with a developer
<?php /** * Example usage for learndash_show_user_course_complete_options filter. */ add_filter( 'learndash_show_user_course_complete_options', 'learndash_show_user_course_complete_options_proc', 10, 3 ); function learndash_show_user_course_complete_options_proc( $enabled, $user_id ) { global $pagenow; // This is set by WordPress for the current page being shown. if ( is_admin() ) { // Example #1 checking based on page viewed if ( ( ( $pagenow == 'profile.php' ) || ( $pagenow == 'user-edit.php' ) ) ) { // Example #2 checking user role. // The learndash_is_admin_user() function is new in LD v2.3 and is the same as using the WordPress // user_can( $user, $capability ) function. if ( learndash_is_admin_user() ) { $enabled = true; } // The learndash_is_group_leader_user() function is new in LD v2.3 and is the same as using the WordPress // user_can( $user, $capability ) function. elseif ( learndash_is_group_leader_user() ) { $enabled = true; } } } return $enabled; }
Changelog #
Version | Description |
---|---|
2.3.0 | Introduced. |