Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Logged in User - Your Recent Post & Your Recent Comments WordPress

  • SOLVED

I am building a wiki site that requires all users to be logged in, in order to see the content.

In the footer I would like 4 widgets:

- Recent Posts (This is working fine)
- Recent Comments (This is working fine)
- Your Recent Posts
- Your Recent Comments


I would like 'Your Recent Posts' to show the last 5 posts that the logged in user has created.
I would like 'Your Recent Comments' to show the last 5 comments that the logged in user has made.

I'm not sure if there is a plugin out there that can do this or someone can help edit the current widgets to do this?

Answers (4)

2012-05-30

Agus Setiawan answers:

logged user recent post :

<?php
if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
query_posts( "author=$user_id&posts_per_page=5" );?>

<ul>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?></a>
</li>

<?php endwhile; else: ?>
</ul>
<p><?php _e('You Have No Submissions'); ?></p>

<?php endif; ?>
<?php
wp_reset_query();
} else {
('You Have No Submissions.');
}
?>


Agus Setiawan comments:

for recent comments by logger user, use this plugin :

http://blog.ashfame.com/2011/01/show-recent-comments-particular-user-wordpress/

hope this can help you

2012-05-30

Jurre Hanema answers:

Please install and activate the attached plugin I created. It will add the widgets you are looking for.

They work exactly the same as the "Recent Posts" and "Recent Comments" widgets included with Wordpress, except they only show the posts or comments from the currently logged in user. If no user is logged in, the widgets don't show anything.


Ross Gosling comments:

Thank you for creating the plugins. I actually used your widget for 'Your Recent Articles' but I used Agus's recommendation for the 'Your Recent Comments' solution as that worked straight out the box.

Thank you

2012-05-30

Francisco Javier Carazo Gil answers:

Hi,

Try this plugin: http://wordpress.org/extend/plugins/special-recent-posts/


Francisco Javier Carazo Gil comments:

Sorry, I hadn't seen your attachment.

Send me code of the plugin/function that generate your widget and I can custom it to make it only post own posts or own comments in the two cases you need.

2012-05-30

Arnav Joy answers:

I can help you by creating new widgets