get_others_unpublished_posts

Retrieves editable posts from other users.

Description

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

Returns (array)

List of posts from others.

Parameters (2)

0. $user_id (int)
User ID to not retrieve posts from.
1. $type — Optional. (string) => 'any'
Post type to retrieve. Accepts draft,, pending or any. (all). Default any..

Usage

  1. if ( !function_exists( 'get_others_unpublished_posts' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/deprecated.php'; 
  3.  
  4. // User ID to not retrieve posts from. 
  5. $user_id = -1; 
  6.  
  7. // Optional. Post type to retrieve. Accepts 'draft', 'pending' or 'any' (all). 
  8. // Default 'any'. 
  9. $type = 'any'; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = get_others_unpublished_posts($user_id, $type); 
  13.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/deprecated.php  
  1. function get_others_unpublished_posts( $user_id, $type = 'any' ) { 
  2. _deprecated_function( __FUNCTION__, '3.1.0' ); 
  3.  
  4. global $wpdb; 
  5.  
  6. $editable = get_editable_user_ids( $user_id ); 
  7.  
  8. if ( in_array($type, array('draft', 'pending')) ) 
  9. $type_sql = " post_status = '$type' "; 
  10. else 
  11. $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) "; 
  12.  
  13. $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC'; 
  14.  
  15. if ( !$editable ) { 
  16. $other_unpubs = ''; 
  17. } else { 
  18. $editable = join(', ', $editable); 
  19. $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) ); 
  20.  
  21. return apply_filters('get_others_drafts', $other_unpubs);