WordPress开发者和主题制作者的搜索引擎



get_users_drafts ›

Since2.0.0
已弃用n/a
get_users_drafts ( $user_id )
参数:
  • (int) $user_id User ID.
    Required: Yes
返回:
  • (array)
定义在:
文档:

Retrieve the user's drafts.



源码

function get_users_drafts( $user_id ) {
	global $wpdb;
	$query = $wpdb->prepare( "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id );

	/**
	 * Filters the user's drafts query string.
	 *
	 * @since 2.0.0
	 *
	 * @param string $query The user's drafts query string.
	 */
	$query = apply_filters( 'get_users_drafts', $query );
	return $wpdb->get_results( $query );
}