Advertisements

get_others_unpublished_posts

Definition:
function get_others_unpublished_posts($user_id, $type='any') {}

Retrieve editable posts from other users.

Parameters

  • int $user_id: User ID to not retrieve posts from.
  • string $type: Optional, defaults to ‘any’. Post type to retrieve, can be ‘draft’ or ‘pending’.

Return values

returns:List of posts from others.

Defined filters

  • get_others_drafts
    apply_filters('get_others_drafts', $other_unpubs)

Source code

function get_others_unpublished_posts($user_id, $type='any') {

	_deprecated_function( __FUNCTION__, '3.1' );



	global $wpdb;



	$editable = get_editable_user_ids( $user_id );



	if ( in_array($type, array('draft', 'pending')) )

		$type_sql = " post_status = '$type' ";

	else

		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";



	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';



	if ( !$editable ) {

		$other_unpubs = '';

	} else {

		$editable = join(',', $editable);

		$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );

	}



	return apply_filters('get_others_drafts', $other_unpubs);

}

9548

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: