i needed a voting system for a client’s wordpress website so i installed this plugin: kk Star Ratings
the standard version is great but has very few options. the quickest way to achieve what the client wanted was to customize the plugin a little bit
show voting only for logged in users
i had to replace the voting box with a message inviting the user to login/signup
i edited the file /wp-content/plugins/kk-star-ratings/index.php
search for this line:
1 |
return $markup; |
and replace it with:
1 2 3 4 5 6 7 8 |
if(function_exists('kk_star_ratings')) { if ( is_user_logged_in() ) { return $markup; } else { echo 'Please login or signup to vote'; } } |
of course you can include HTML code between ‘ ‘ to further edit the message: include a link to login page, change the appearance (float, background)
hide voting on some posts
with kk Star Ratings you can choose where you want the ratings to be placed (homepage, archives, posts, pages, categories) but you can’t hide it from some posts (custom posts in my case)
so i edited the file /wp-content/plugins/kk-star-ratings/index.php
search for this line:
1 |
return $markup; |
and replace it with:
1 2 3 4 5 6 7 |
if(function_exists('kk_star_ratings')) { if(!in_array(get_the_ID(), array(101,151,1001))) { return $markup; } } |
where 101,151,1001 from the array are the ID’s of the posts