Admin::posts_clauses_request( $clauses )


Source

File: classes/Admin.php

	public function posts_clauses_request( $clauses ) {
		global $wpdb;

		$user_id = get_current_user_id();
		
		$courses_ids = $wpdb->get_col( "SELECT course_id from {$wpdb->dozent_instructor_courses} WHERE instructor_id = {$user_id}  " );

		$custom_author_query = "AND {$wpdb->posts}.post_author = {$user_id}";
		if ( dozent_count( $courses_ids ) ) {
			$in_query_pre = implode( ',', $courses_ids );
			$custom_author_query = "  AND ( {$wpdb->posts}.post_author = {$user_id} OR {$wpdb->posts}.ID IN({$in_query_pre}) ) ";
		}

		$clauses['where'] .= $custom_author_query;

		return $clauses;
	}