Warning: This function has been deprecated. Use get_posts() instead.

get_others_unpublished_posts() WordPress Function

The get_others_unpublished_posts() function retrieves a list of all posts that are unpublished by other users. This can be useful for checking what content is awaiting approval, or for finding unpublished drafts that may have been forgotten about.

get_others_unpublished_posts( int $user_id, string $type = 'any' ) #

Retrieves editable posts from other users.


Description

Top ↑

See also


Top ↑

Parameters

$user_id

(int)(Required)User ID to not retrieve posts from.

$type

(string)(Optional) Post type to retrieve. Accepts 'draft', 'pending' or 'any' (all).

Default value: 'any'


Top ↑

Return

(array) List of posts from others.


Top ↑

Source

File: wp-admin/includes/deprecated.php

function get_others_unpublished_posts( $user_id, $type = 'any' ) {
	_deprecated_function( __FUNCTION__, '3.1.0' );

	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);
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Use get_posts()
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More