Retrieve the post SQL based on capability, author, and type.

Signature

get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false )
post_type
 (string) Post type.
full
 (boolean) Optional. Returns a full WHERE statement instead of just an 'andalso' term.
Default: true
post_author
 (int) Optional. Query posts having a single author ID.
Default: null
public_only
 (boolean) Optional. Only return public posts. Skips cap checks for $current_user. Default is false.
Default: false

Return

(string) SQL WHERE code that can be added to a query.

Source

function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
	global $user_ID, $wpdb;

	// Private posts
	$post_type_obj = get_post_type_object( $post_type );
	if ( ! $post_type_obj )
		return $full ? 'WHERE 1 = 0' : ' 1 = 0 ';

	// This hook is deprecated. Why you'd want to use it, I dunno.
	if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) )
		$cap = $post_type_obj->cap->read_private_posts;

	if ( $full ) {
		if ( null === $post_author ) {
			$sql = $wpdb->prepare( 'WHERE post_type = %s AND ', $post_type );
		} else {
			$sql = $wpdb->prepare( 'WHERE post_author = %d AND post_type = %s AND ', $post_author, $post_type );
		}
	} else {
		$sql = '';
24 more lines...
WP Trac GitHub Bitbucket

Link here