public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/admin/functions.php
/**
 * This function filters the users by course and author id.
 *
 * Currently this does not work properly.
 *
 * @since 1.0.0
 *
 * @param object $query The WP_User_Query object for modification.
 */
This function filters the users by course and author id.
Currently this does not work properly.



@param object $query The WP_User_Query object for modification.
This function filters the users by course and author id . Currently this does not work properly . @param object $query The WP_User_Query object for modification .
function WPCW_users_permissionUsersFilter( $query ) {
	if ( ! is_admin() ) {
		return;
	}
	global $wpdb, $wpcwdb;
	$current_user = wp_get_current_user();
	if ( user_can( $current_user, 'manage_wpcw_settings' ) ) {
		return;
	}
	$search_users = array();
	$course_users = $wpdb->get_results( $wpdb->prepare( "
    	SELECT *
    	FROM $wpcwdb->user_courses uc
    	LEFT JOIN  $wpcwdb->courses c ON c.course_id = uc.course_id
   		WHERE course_author = %d
   		ORDER BY course_title ASC
    ", $current_user->ID ) );
	 returned data.
	if ( $course_users ) {
		foreach ( $course_users as $course_user ) {
			if ( isset( $course_user->user_id ) ) {
				$search_users[] = $course_user->user_id;
			}
		}
	}
	$query->set( 'exclude', array_unique( $search_users ) );
}
function WPCW_users_permissionUsersFilter ( $ query ) { if ( ! is_admin ( ) ) { return ; } global $ wpdb , $ wpcwdb ; $ current_user = wp_get_current_user ( ) ; if ( user_can ( $ current_user , 'manage_wpcw_settings' ) ) { return ; } $ search_users = array ( ) ; $ course_users = $ wpdb -> get_results ( $ wpdb -> prepare ( " 
    	SELECT *
    	FROM  $ wpcwdb -> user_courses  uc
    	LEFT JOIN   $ wpcwdb -> courses  c ON c.course_id = uc.course_id
   		WHERE course_author = %d
   		ORDER BY course_title ASC
     " , $ current_user -> ID ) ) ; if ( $ course_users ) { foreach ( $ course_users as $ course_user ) { if ( isset ( $ course_user -> user_id ) ) { $ search_users [ ] = $ course_user -> user_id ; } } } $ query -> set ( 'exclude' , array_unique ( $ search_users ) ) ; }
This function filters the users by course and author id.
This function filters the users by course and author id .
// Check // Globals // Vars // If admin, return. // Users array // Get users of course this author has created. // Check returned data. // Set the query paramater