Definition:
function get_most_recent_post_of_user( $user_id ) {}
Get a user’s most recent post.
Walks through each of a user’s blogs to find the post with the most recent post_date_gmt.
Parameters
- int $user_id
Return values
returns:Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
Source code
function get_most_recent_post_of_user( $user_id ) {
global $wpdb;
$user_blogs = get_blogs_of_user( (int) $user_id );
$most_recent_post = array();
// Walk through each blog and get the most recent post
// published by $user_id
foreach ( (array) $user_blogs as $blog ) {
$recent_post = $wpdb->get_row( $wpdb->prepare("SELECT ID, post_date_gmt FROM {$wpdb->base_prefix}{$blog->userblog_id}_posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A);
1490

February 12, 2011 


No comments yet... Be the first to leave a reply!