It sound like the order by might need looking at
There are 2 options in the Sorting order: option – number of posts and recent activity
Have you tried to set these as it should override any default. So if its not working I feel that we have found a bug.
please do some more testing as I don’t have a test install with any real data
If you wish to hack the code feel free to pull from https://github.com/pbearne/wp-author-avatars/ I will add any patch you submit
Note there is breaking CSS change in the head .multiwidget => .widget
Paul
Number of posts is not quite the same as most recent post. The plugin itself doesn’t have a bug. You use a function called get_user_last_activity which checks if BP is running and uses the BP activity. If BP is not running it uses the most recent post.
Original code:
function get_user_last_activity($user_id) {
if (AA_is_bp()) {
return gmdate( 'Y-m-d H:i:s', (int)get_user_meta( $user_id, 'last_activity' ) );
}else{
global $wpdb;
$query = $wpdb->prepare(
"SELECT p.post_date
FROM $wpdb->posts p
WHERE
p.post_status = 'publish'
AND
p.post_author = %d
ORDER BY p.post_date
DESC LIMIT 1",
$user_id
);
return $wpdb->get_var( $query);
}
}
The other issue is that it only looks at posts table without regard for the post type. So if you have admins in there, it will count things like pages, added products etc… So in our case I also only wanted to use actual blog posts and not other posts so in the query I set the post type to posts.
Here is the hacked version:
// pluginhack
// if (AA_is_bp()) {
// return gmdate( 'Y-m-d H:i:s', (int)get_user_meta( $user_id, 'last_activity' ) );
// }else{
global $wpdb;
$query = $wpdb->prepare(
"SELECT p.post_date
FROM $wpdb->posts p
WHERE
p.post_status = 'publish'
AND
p.post_type = 'post'
AND
p.post_author = %d
ORDER BY p.post_date
DESC LIMIT 1",
$user_id
);
return $wpdb->get_var( $query);
}
// }
The hack is not appropriate for contribution to the plugin because its a dirty fix for my own specific purposes. However it shouldn’t take long to break out the options a little more to include recent post as a sorting option.
Have a look!
OK
I need to work this through from the select option
and I take you point about post type
It looks like I need to add the ability to select post types to count and set just posts as the default
Thanks for the spot
More work 🙂
Paul