On this page
get_others_unpublished_posts( int $user_id, string $type = 'any' ): array
This function has been deprecated. Use get_posts() instead.
Retrieves editable posts from other users.
Description
See also
Parameters
$user_idint Required-
User ID to not retrieve posts from.
$typestring Optional-
Post type to retrieve. Accepts
'draft','pending'or'any'(all).
Default'any'.Default:
'any'
Return
array List of posts from others.
Source
File: wp-admin/includes/deprecated.php. View all references
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);
}
Related
Uses
| Uses | Description |
|---|---|
| get_editable_user_ids() wp-admin/includes/deprecated.php | Gets the IDs of any users who can edit posts. |
| _deprecated_function() wp-includes/functions.php | Marks a function as deprecated and inform when it has been used. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| wpdb::get_results() wp-includes/class-wpdb.php | Retrieves an entire SQL result set from the database (i.e., many rows). |
| wpdb::prepare() wp-includes/class-wpdb.php | Prepares a SQL query for safe execution. |
Used By
| Used By | Description |
|---|---|
| get_others_drafts() wp-admin/includes/deprecated.php | Retrieve drafts from other users. |
| get_others_pending() wp-admin/includes/deprecated.php | Retrieve pending review posts from other users. |
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Use get_posts() |
| 2.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_others_unpublished_posts