To prevent comments from protected pages from appearing in “Recent comments” widget, open up “/wp-includes/widgets.php” and replace the function “wp_widget_recent_comments” with this code:
function wp_widget_recent_comments($args) {
global $wpdb, $comments, $comment, $current_user;
extract($args, EXTR_SKIP);
$options = get_option(’widget_recent_comments’);
$title = empty($options['title']) ? __(’Recent Comments’) : apply_filters(’widget_title’, $options['title']);
if ( !$number = (int) $options['number'] )
$number = 5;
else if ( $number < 1 )
$number = 1;
else if ( $number > 15 )
$number = 15;
if ( !$comments = wp_cache_get( ‘recent_comments’, ‘widget’ ) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1′ AND comment_post_ID NOT IN (SELECT post_id FROM " . $wpdb->prefix . "named_users WHERE (user_id <> " . $current_user->ID . " OR group_id NOT IN (SELECT group_id FROM " . $wpdb->prefix . "named_users_groups_relations WHERE user_id = " . $current_user->ID . "))) ORDER BY comment_date_gmt DESC LIMIT $number");
wp_cache_add( ‘recent_comments’, $comments, ‘widget’ );
}
?>
<?php echo $before_widget; ?>
<?php echo $before_title . $title . $after_title; ?>
<ul id="recentcomments"><?php
if ( $comments ) : foreach ( (array) $comments as $comment) :
echo ‘<li class="recentcomments">’ . sprintf(__(’%1$s on %2$s’), get_comment_author_link(), ‘<a href="’. get_comment_link($comment->comment_ID) . ‘">’ . get_the_title($comment->comment_post_ID) . ‘</a>’) . ‘</li>’;
endforeach; endif;?></ul>
<?php echo $after_widget; ?>
<?php
}
global $wpdb, $comments, $comment, $current_user;
extract($args, EXTR_SKIP);
$options = get_option(’widget_recent_comments’);
$title = empty($options['title']) ? __(’Recent Comments’) : apply_filters(’widget_title’, $options['title']);
if ( !$number = (int) $options['number'] )
$number = 5;
else if ( $number < 1 )
$number = 1;
else if ( $number > 15 )
$number = 15;
if ( !$comments = wp_cache_get( ‘recent_comments’, ‘widget’ ) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = ‘1′ AND comment_post_ID NOT IN (SELECT post_id FROM " . $wpdb->prefix . "named_users WHERE (user_id <> " . $current_user->ID . " OR group_id NOT IN (SELECT group_id FROM " . $wpdb->prefix . "named_users_groups_relations WHERE user_id = " . $current_user->ID . "))) ORDER BY comment_date_gmt DESC LIMIT $number");
wp_cache_add( ‘recent_comments’, $comments, ‘widget’ );
}
?>
<?php echo $before_widget; ?>
<?php echo $before_title . $title . $after_title; ?>
<ul id="recentcomments"><?php
if ( $comments ) : foreach ( (array) $comments as $comment) :
echo ‘<li class="recentcomments">’ . sprintf(__(’%1$s on %2$s’), get_comment_author_link(), ‘<a href="’. get_comment_link($comment->comment_ID) . ‘">’ . get_the_title($comment->comment_post_ID) . ‘</a>’) . ‘</li>’;
endforeach; endif;?></ul>
<?php echo $after_widget; ?>
<?php
}
hey, fantastic, i put in my blog and now it’s ok, thank you its a great plugin… you are a genius.
Great plugin, but one issue: if I protect one page with content “bla bla” and then search for “bla bla” with unprivileged user, the content (also article’s title and id) is revealed as part of search result. Any ideas how to avoid that leak?
Thank you,
skipr
I will try to fix it as soon as possible.
Are you sure that this error exists? I have a protected page on this site with the title “Protected page” and contents “This is a protected page.”. Try searching for it!
Hi,
This is a great plugin, thank you !
I just want to allow user accounts with “Editor” privileges to manage access / rights to Posts / Pages with your plugin because only “Admin” can access the rights management panel. Where is the rights filter ?
Thanx,
GROUPS allows me to create new groups and assign users to that group, thats cool BUT i need groups to also show the pre-existing ROLES and give people designated a certain ROLE access as if say Editor, Subscriber, GOLD member, Silver Member, etc (some of my ROLES) were groups can you either add it or tell me what code to change to read from the current list of roles instead of the GROUPS list used by this addon?
i currently have several ROLES assigned to users depending usually on their membership status, these include
Administrator | Editor | Subscriber | Bronze Member | Silver Member | Gold Member
so i really need these ROLES to show up as groups or something like that last thing i want to do is have 2 download a new (membership creation via paypal plugin) that is specifically designed to be compatible with the creation of GROUPS used in this plugin, please tell me what code variables to change or add it to the code, this is the closest plugin ive found for some of the things im trying to do ( mostly displaying / not displaying specific content on pages and specific menus on the menu bar depending on user ROLE level ) please reply also to email if possible thanks…
I have installed the plugin and it looks to be a great plugin. Will help me a lot. The only thing is that I cant see any sign in box. Is this pugin supposed to work in conjunction with another plugin? In my Members pages in the link in the side bar. The only page that appears on the page tabs accross the top is the one page that I have cleared permisions for and want as a public page. The rest I have set up for members. I have aded one user and group but there is nowhere for him to sign in. I’m probably just missing wher to find a setting or something. I have posted relentlesly in forums, searched forums, searched google, and can find no help. Would appreciate anything you could do.
Kim Parsell has written this tutorial: http://www.kpdesign.net/wordpress/allowing-limiting-user-access-in-wordpress/
Great extension, it’s a must to use, very professional. I’m setting up a professional Wordpress site, and this is exactly the services I was looking for. One (little) complain : the un-installation of the extension need a manual drop of the database tables. On the occasion, a nice link to do it for the admin should be nice
Thanks,
fanta78
Wordpress: publier des articles et des pages privés…
J’ai eu aujourd’hui besoin de faire une maquette pour un nouveau site, destiné à un public à accès restreint et authentifié. Voyons voir ce que Wordpress propose en standard…
De la visibilité des articles et des pages
Pour comme…
Hi, your plugin looks great! Wouldn’t it be better though to override the recent comments widget in functions.php than editing widgets.php? Such as detailed here: http://www.yoursiteisvalid.com/validnews/override-wordpress-default-widgets-307.html
I haven’t tried it with that specific widget though, so I can’t say if it should work or not. It just seems more sensible as it wouldn’t break with a Wordpress upgrade.
Hi
How you can set right’s so that nobody else than adminstrator can see and change settings?
Edit the source code.
I’m very much novise with these things. Is there anyone, who could simply show me what to edit?
I think the idea is good but you need to modify it a little.
Great plugin, but one issue: if I protect one page with content “bla bla” and then search for “bla bla” with unprivileged user, the content (also article’s title and id) is revealed as part of search result. Any ideas how to avoid that leak?
Thank you,
Hi Andrias,
Is there a (simple) way to add automaticaly any new user into one of the wpnamedusers’s group ?
I have already a great number of pages assigned to permissions through one group.
Each time a new user goes through the subscribtion process, I wish to have his account automaticaly put in this group, as he is set up direclty into the default WP “Contributor” role.
Thanks
This is a great idea for an improvement of the plugin! I will look into it as soon as possible.
i want to show a list of posts for the logged in user
i would guess it some combination of this but….
is_user_logged_in() )
$wpNamedUsers_posts
BTW- this is the most perfect project asset manger plugin out there. it is perfect to use to share files with clients, etc… thank you.
thanks you…