You can add filters to wp_get_archives().
Call wp_get_archives() like this for logged in users:
<?php
if ( is_user_logged_in()) {
global $archive_author_id;
$archive_author_id = get_current_user_id();
// add the filter to wp_get_archives to filter it by user
add_filter( 'getarchives_where' , 'getarchives_where_filter');
wp_get_archives('type=monthly');
// remove the filter
remove_filter( 'getarchives_where' , 'getarchives_where_filter');
} else {
// user is not logged in
wp_get_archives('type=monthly');
echo 'You have to log in to see your personal archive';
}
?>
And put this in your theme’s functions.php:
// alter the sql "where" query for montly archives
function getarchives_where_filter( $where) {
global $archive_author_id;
return $where .' AND post_author = ' . $archive_author_id;
}
// query monthly archives by user.
function my_post_queries( $query ) {
// do not alter the query on wp-admin pages and only alter it if it's the main query
if (!is_admin() && $query->is_main_query()){
// alter the query for monthly archive pages
if(is_archive() && is_month()){
if ( is_user_logged_in()) {
$user_nicename = get_userdata(get_current_user_id())->user_nicename;
$query->set('author_name', $user_nicename);
//$query->set('posts_per_page', 1);
}
}
}
}
add_action( 'pre_get_posts', 'my_post_queries' );