get_others_unpublished_posts()

最后更新于:2021-11-26 10:44:15

get_others_unpublished_posts( int$user_id, string$type=’any’)

Retrieves editable posts from other users.

参数

$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’

响应

(array) List of posts from others.

源文件

文件: gc-admin/includes/deprecated.php

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

	global $gcdb;

	$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 = $gcdb->get_results( $gcdb->prepare("SELECT ID, post_title, post_author FROM $gcdb->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);
}