↑ Zurück zu WordPress-Plugins

NextGEN Gallery Voting tutorial and demo – English version

The WordPress.org-Plugin „NextGEN Gallery Voting“ allows visitors to rate individual pictures on your website. You can use this feature in order to make photo-contest where the visitors of your homepage can vote the best pictures.

IMPORTANT: I deactivated the voting because I found a better way to interact with my clients: TTG CE3 Client Response Gallery.

You cand find a demo of the TTG CE3 Client Response Gallery here. Username „Foto“. Password „Shooting“.

IIf you find errors in my spelling or grammar please leave a comment below and tell me. If you have any questions, you can also leave a comment.

1. Installation:

NextGEN Gallery Voting is an addon for „NextGEN Gallery“. So you have to install „NextGEN Gallery“ first. Afterwards you have to install „NextGEN Gallery Voting“.

If you have done this, you can find a new menu in your backend: „NGG Voting Defaults“. Here you can choose the settings for new galleries. These are my Settings.

These settings ONLY change the behavour of NEW galeries. The existing galeries and pictures are NOT affected. For those you have to do it manually for each picture and gallery or you can use the SQL-commands below.

The voting funktion for galeries works just fine and out of the box. The voting feature for individual pictures does NOT work that easily. First you have to change the file:



You have to insert the new line „<?php echo nggv_imageVoteForm($image->pid); ?>“

The file looks like this on my server. If it does not work this way on your website, try to put the new line a bit higher or lower. Trial and error gives the best results here. Click on the picture to see it in full size.


2. Activate voting for all pictures (including old ones)

You need acess to your SQL-Database. More precisely you need acess to the chart:


In the pictures below i explain how to get to the chart „wp_nggv_settings“ and how to run the commands. Click on the pictures to see them in full size.



Here you run the command:

UPDATE  `database_name`.`wp_nggv_settings` SET  `enable` =  '1',
`force_once` =  '1',
`voting_type` =  '2' WHERE  `wp_nggv_settings`.`pid` >0

The same command with enable=0 deaktivates Voting on all pictures.

3. Activate voting for all galeries (including old ones)

Here you run the SQL-command

UPDATE  `database_name`.`wp_nggv_settings` SET  `enable` =  '1',
`force_once` =  '1',
`voting_type` =  '2' WHERE  `wp_nggv_settings`.`pid` =0

The same command with enable=0 deaktivates voting on all galeries.

4. Ban bots and spiders from voting

If you activate „star rating“, spiders and crawlers will click on these stars and mess up you voting-results. In order to prevent them from doing so, you have to manipulate your robots.txt.

Here you can see a part of my robots.txt:

User-agent: *
Sitemap: http://c-schaefer-foto.de/sitemap.xml

#blocks all URL with a "?"
#(the ngg-Voting-Links contain a "?")
Disallow: /*?

#blocks only ngg-Voting-Links
Disallow: /?ngg-pid=
Disallow: /*?ngg-pid=

Update: No matter which voting type you activate (star, dike/dislike, drop-down), some of your votes will be submitted by bots, if the page where the voting-form is on is accessible to bots. I found out that approximately 70 % of the votes I get for my pictures are submitted by bots. Most submitter-bots dont care for your robots.txt. The only way to stop bots from voting is making the page where the voting-form is on not-accessible by bots (e.g. using a password or captcha).

4.1 Delete votes that have been cast by bots

I have written a macro for Excel, which finds and deletes the votes that have been submitted by bots. The use of the program is not particularly comfortable, and thus suitable only for users who:

  • Have access to the SQL database
  • Have access to a program that logs the IP’s of the (human) visitors, such as Google Analytics or Piwik
  • Have knowledge of Excel and SQL
  • Trust my VBA macros. If you dont: In the box below is the complete code of the macro.If you want to, you can use it to create your own program. But please let me know.
  • Have backups of their data. I am not liable for data that is accidentally deleted by this program.

You can download program here. All you need to know to run the program is written on the first sheet. If you have questions, write a comment below.

5. More SQL-Kommands

All users have to logg in in order to vote:

UPDATE  `database_name`.`wp_nggv_settings` SET  `force_login` =  '1'

To switch from „drop down“ to „Star-Rating“ or „Like/Dislike“ use the values 1, 2 or 3:

UPDATE  `database_name`.`wp_nggv_settings` SET  `voting_type` =  '1'

Everybody may vote only once:

UPDATE  `database_name`.`wp_nggv_settings` SET  `force_once` =  '1'

Users see the results:

UPDATE  `database_name`.`wp_nggv_settings` SET  `user_results` =  '1'

6. Edit or delete votes that have been cast:

You have to manipulate the chart „wp_nggv_votes“.


You like this article? Tell your friends about it!

You have questions? Write a comment!

4 Kommentare

Zum Kommentar-Formular springen

  1. kalotina

    Hi there…
    I use your information.
    Working but the vote button is not down in the picture but left…
    how to fix them?

    1. Constantin

      I think you have to insert the new line “< ?php echo nggv_imageVoteForm($image->pid); ?>” in an other place in the file „gallery.php“.

      Just try a few different places and it might work then. Or try a different voting type (stars, drop down, …)

  2. Anshuman

    Thank you for the much needed help, but I couldn’t quite understand the step 2, the SQL function. Could you please explain how I can „run“ a command? I’ve gained access to MySQL account successfully but don’t know where to put the code you gave.

    1. Constantin

      Thank you for your comment. I uploaded some pictures to explain it. i hope, you can find it now.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.