WordPress.org

Support

Support » Plugins and Hacks » Post Ratings » [Plugin: Post Ratings] Option to disalow authors to vote in their own posts

[Plugin: Post Ratings] Option to disalow authors to vote in their own posts

  • Hi!

    Love your plugin, great code that really respects wordpress parameters.

    However I have a small feature request, can you please add an option to disallow post authors to vote in their own posts?

    This is a very important option to the site I’m working on, so I’ve done this manually, but an option in the admin panel would avoid code changes on every plugin update.

    Thank you!

    http://wordpress.org/extend/plugins/post-ratings/

Viewing 1 replies (of 1 total)
  • Plugin Author digitalnature

    @digitalnature

    I don’t think a plugin option is necessary for this. But if more people request it, I’ll add one.

    To disallow post authors to vote on their own posts, drop this code in the .php file that you use for your customizations (theme functions.php?)

    add_filter('post_ratings_access_check', 'no_ratings_for_authors', 10, 2);
    
    function no_ratings_for_authors($passed_checks, $post_id){
    
      // not a logged in user, or default checks failed
      if(!$passed_checks || !is_user_logged_in())
        return $passed_checks;
    
      $current_user = wp_get_current_user();
      $post = &get_post($post_id);
    
      // the post doesn't belong to this user
      if($current_user->ID != $post->post_author)
        return true;
    
      // it does, disallow ratings
      return false;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Post Ratings] Option to disalow authors to vote in their own posts’ is closed to new replies.
Skip to toolbar