Democracy plugin

10th Oct 2006 Danny

Plugin updated 28th January 2008 - Please ensure you have the latest version installed

Democracy Poll is a plugin for b2evolution that adds a poll to your blog's sidebar. You can create and edit polls in the Tools > Democracy tab of the b2evolution backoffice. If the user has JavaScript enabled, their vote is sent without refreshing the whole page. Results can be displayed as a pie chart or as a bar graph.

Original Wordpress plugin by Andrew Sutherland

Ported to b2evolution by Danny Ferguson

Released under the CC GPL 2.0


  • Uses AJAX for sending and loading the results, but is fully accessible in non-js environments
  • Complete admin panel
  • Support for multiple blogs.
  • When someone votes, they receive a cookie with what poll they voted in and what their vote was. It also logs their IP, so the same person can't vote twice even if they delete the cookie
  • Allows users to see current results without voting. Also, detects if there are no votes and announces it...
  • After voting, the choice you made is highlighted.
  • Automatic database table installation.
  • Displays winners of each poll in the admin panel.
  • Delete old polls in the admin panel.
  • Edit existing polls.
  • AJAX is compatible with IE 6, Safari, Firefox, and Opera. All the other browsers, and those with javascript turned off, are supported as well.
  • Select an active poll.
  • Allow your users to add their own choices.
  • Uses the date format you set in the Options panel for the Date Added column.
  • Marks which answers have been added by users, if applicable.
  • Option to allow a poll's results to be displayed as a pie chart
  • Has an archiving function for displaying past polls
  1. Introduction
  2. Installation (v1.8)
  3. Installation (v2.x)
  4. Customization


Comment from: John
Well done.
I want to locate the Democracy Poll on a specific Poll page the same as .arcdire etc called by something like
Would I need to change paths to associated scripts/files or is the whole idea of not adding this to _main.php a no no?

10/11/06 @ 01:30
Comment from: Danny
Thank you. If you look at the customization section (page 3 of this post), you'll find instructions for adding an archive page. That's the same idea you'll want to follow to display the poll on it's own disp=poll page. Just change the 'pollarchives' to 'poll' and change the plugin call to match the call that you would have put in the sidebar. Let us know how that works out.
10/11/06 @ 02:08
I'm having two problems with democracy poll.

1. Cannot or delete answers in admin. The links doesn't work.
2. How exactly do I get the bar graph to show up?

Otherwise great job :)
10/18/06 @ 19:50
I'm having one problem with democracy poll:

I copy the democracy_plugin directory in plugins directory.

When I go to Settings > Plugins my server respond:
"The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings."

I must delete "democracy_plugin" directory from "plugins" directory. :(

Many thanks for your kindness.

10/25/06 @ 09:08
Comment from: Perry
Hi: Thanks for this great plugin.

I installed it on 1.8.2 fine, but when I validated the site using many HTML errors are displayed. Is this an issue??

10/30/06 @ 11:45
Same problem of the other user:

Cannot add or delete answers in admin. The links doesn't work. (script error)
11/03/06 @ 09:55
Sorry it's taken a smidge to reply but Scotts been wandering round Canada, Danny's been getting to grips with his new job and I got waylaid by a project with a tight deadline.

As soon as we get a chance we'll take a look and see if all these problems can be cured.

If anyone finds any others, please post them here and we'll add them to our todo list

11/03/06 @ 11:47
Comment from: RCG
Although my blog (1.8.2) is not on-line yet, I experienced some errors during the test-fase of it. I installed this poll tool (zip currently on this page - b2evo calls it 1.5, the readme says 1.2) and added it to my skin exactely as you described. The following errors occurred
Notice: Undefined index: display in c:\program files\easyphp1-8\www\blogs\plugins\democracy_plugin\_democracy.plugin.php on line 418

--Added By Democracy Plugin. Version 1.5 --script type="text/javascript"
var SendDemocracy = "http://localhost/blogs/htsrv/call_plugin.php?plugin_ID=14&method=cast_vote&demSend=true";
var GetDemocracy = "http://localhost/blogs/htsrv/call_plugin.php?plugin_ID=14&method=cast_vote&demGet=true";

Notice: Undefined variable: poll_id in c:\program files\easyphp1-8\www\blogs\plugins\democracy_plugin\_democracy.plugin.php on line 438

Notice: Undefined index: jal_no_js in c:\program files\easyphp1-8\www\blogs\plugins\democracy_plugin\_democracy.plugin.php on line 442

-- There are no active polls in the database, or there was an error in finding one --

I made a poll in the admin-interface (errors occurred in there, too, but just little) but the result was even worse. Is there something wrong with my versions?
11/16/06 @ 21:01
Swift update : I've cured (I think) all of the problems/errors that have been reported here and updated the zip file so just download it again and upload the plugin to you rserver.

For those of you on a windows box (not sure if it affects *nix boxes) there's still an "unserialize" error when casting a vote ( thanks to ednong for pointing that one out), I'm working on it :|

If you find any more errors that we've missed just let us know ;)

11/18/06 @ 13:19
Comment from: RCG
I'm testing on a windows machine right now (my wireless internet is not happy with linux :( ). However, my site will be hosted on a *nix (SUSE afaik.) I do not find any error messages any more now, but i'm not allowed to vote either. Maybe that's a matter of spam (localhost) protection or something like that. If I know which is the case, i'll let it know you. Thanks a lot so far ;)
11/20/06 @ 16:48
Comment from: RCG
Excuses-moi ... ;)

After making a new poll i was able to vote. And the old poll worked again after deleting the cookies. Off course: votes are registered in the database, but on the user-side with cookies so that they know they have voted already. The unserialize error has occored to me, too. I'll wait for the solution...
11/20/06 @ 17:07
Comment from: RCG
Another bug report from my side (windows XP; apache; php 4.3.1 and mysql 4.1.9) These two messages appear whenever you want to view the results.

Above the result-bars:
Notice: Undefined index: b2demVoted_1 in c:\program files\easyphp1-8\www\blogs\plugins\democracy_plugin\_democracy.plugin.php on line 829
And under them:
Notice: Undefined index: b2demVoted_1 in c:\program files\easyphp1-8\www\blogs\plugins\democracy_plugin\_democracy.plugin.php on line 893

And sometimes the unserialize error off course.
I'm pretty sure that i'v reported any error that occurred me now. Thanks in advantage.
11/20/06 @ 22:17
Comment from: db
The download is not working
11/22/06 @ 22:08
Hi DB, try the download again now and see if it works. If not then just let us know and we'll email you the zip instead.

Hi RCG, Thanks for that, I've now cleared those two errors as well (and updated the zip). We're still working on the serialize problem though so bear with us.

11/23/06 @ 07:32
is there a way to shrink the graph? Also, is there a way to reduce the white space between the different questions?

By the way, the install & config was a charm! Great job.

11/24/06 @ 06:02
Comment from: Kyle
I was just wondering if there was a solution for the validation failures. At this point my site won't validate for either XHTML or CSS. It mainly has to do with the use of ampersands and less than symbols in data. Hopefully there is a solution for this problem.
11/28/06 @ 03:57
Once again the plugin zip has been updated, you should find that it cures the serialization and validation errors.

There's still still some validation warnings that we're working on.

12/09/06 @ 09:40
Comment from: EdB
The end of your readme files spells "astonishme" with only one "s", but that's not what's on my mind. The results of a poll, after voting, are in a skinny little pie chart in my sidebar. This, to me, looks like warm crap. I'd think it would be either full width of the containing div or controllable via the plugin's parameter array. The best is the first. The second is just because not everyone accepts my extreme wisdom as that. The third option would be to pour up a tall one and not sweat it ;)
12/24/06 @ 09:41
Comment from: Danny
Your first option would be ideal, but swf charts has to be given a width in pixels. Having that as a parameter may be a good option in the meantime, but if you look at the plugin php file you'll see that it's not too hard to edit that and other parameters.
12/24/06 @ 14:43
Comment from: EdB
Cool. Didn't know the one or think of the other, but I just poked around in the code and tweaked this and that a bit. Groovy!
12/28/06 @ 12:15
Comment from: Paul
Bit new to the whole blogging thing, but tried adding the democracy plugin as directed. It shows up fine when viewed on my laptop. However, on every other Windows machine I've seen, the following appears instead of the chart:


Any clues as to what's going on?
01/01/07 @ 21:43
Try changing "Today's Poll" to "Todays Poll"

01/02/07 @ 11:09
I have ver 1.8.6 installed. The code is written as follows, but won't show in my unpublished blog: call_by_code( 'democrcy', array() ); // -------------------------------- END OF CATEGORIES ---------------------------------- ?> [b] call_by_code( 'democrcy', array( 'gct' => '#F00', 'gcb' => '#D00' ) ); // -------------------------------- END OF DEMOCRACY POLL ---------------------------- ?>[/b]
01/11/07 @ 08:40
Comment from: MrStatic
I keep getting
Notice: Trying to get property of non-object in /usr/home/static/tatersalad_net/plugins/democracy_plugin/_democracy.plugin.php on line 448
01/12/07 @ 08:00
Comment from: Paul
Thanks for the advice ¥åßßå - did the trick I think
01/21/07 @ 03:53
Can this plugin be updated so polls can be stuck in posts.
02/03/07 @ 09:32
I haven't looked into it, but you could probably/possibly add a renderer (you'd need to use DisplayItemAsHtml for 1.9.2 to bypass the pre-rendered content issues) so you could include a poll in your post

02/03/07 @ 12:31
problem with the check of ip addresses. as this is a very local and area based website most people are connected to the same provider. NTL in this case and they very often assign the same proxy ip address. which means different users are seen as the same user.

the quick solution was to disable in _democracy.plugin.php:

$all_ips = $DB->get_var("SELECT voters FROM ".$this->get_sql_table('Q')." WHERE {$where}");

now it is fine, but of course people can now vote as often as they want as soon as their cookie has expired.

any other solution???
02/25/07 @ 12:30
Comment from: Danny
You could also check the user id number, if the person is logged in. That would really only be helpful if you only let logged in users vote in the poll. Aside from that, cookies and IP address are the only ways I know how to limit voting.
02/25/07 @ 23:58
Comment from: dub27
version 1.9.2

plugin loaded fine
show toggle to always
include added to _main.php

no tab option shows up under tools in the admin panel

any ideas?
02/27/07 @ 17:17
Comment from: dub27
Hi, for some reason the poll is now showing up in the tools panel, not sure why it was not showing before...

Just wanted to let you know and say thanks!
02/27/07 @ 19:30
Comment from: Paul
how can i have it display a bar graph instead of a pie chart?
03/15/07 @ 03:06
Hi Paul,
If you hit admin > tools > democracy, you'll see a checkbox for "display results as a pie chart", you just need to untick it.

To do this with an already active poll you just need to click "edit" and then change the option

03/15/07 @ 09:53
Your plug-in is terrific. Thank you so much. I'm not sure if we are having a problem with it or not. We get a few hundred unique visitors per day so its possible that many of them are just opionless boobs... We put up a poll each day and whatever the top answer is (even if is "I'm an opinionless boob") It gets 60-100 votes while the rest get single digits. You can check it out here-

Please let me know if you have any idea what's going on.

03/30/07 @ 02:37
Comment from: Hans Chr. Andersen

Very nice job indeed ;-)

I need to translate some of the messages to danish, and so far so good, but, I cannot find where to change the [Vote] text on the submit bottom :-(

Please, someone, point me in the right direction ;-)

I have made a complete search in the plugin source code, but without any luck.

Please ?
03/30/07 @ 12:48
Comment from: Danny
As I told Sammy via email, this is probably due to spammers going through the site following every link and submitting every form they come to. We'll address this int he next version.
03/31/07 @ 17:46
Comment from: Shasta
The polls work, it's just that for some reason the .css file for the plugin is called before any of the other .css files. When the browser tries to load the democracy.css file, it comes up with a file not found error. So i don't get the little bars for answers. I have the democracy.css file in the plugins directory of my site. Is there a different place i should put it?
04/07/07 @ 03:30
It looks like you solved this problem?

04/09/07 @ 08:41
I love this plugin.

However, I've tried to change the background color of the chart (pie chart, when showing the result) to the bg I have the the sidebar. But when I do, I get a two-coloured background. It'd seem that the rectangles containing the result and the chart shows with the right background colour, but around them it's a darker shade of that colour. Maybe I'm just blind, who can't find the reason for this, but please point me in the right direction.

Cheers / W
05/09/07 @ 17:58
Correction: sorry. The problem is not that the surrounding area is darker, but that some parts of the image showing the chart and the result, is in a brighter shade of the background. I'm almost certain... Still very annoying that it's different colours instead of just the singe one I've defined in the PHP-script.
05/09/07 @ 18:45
Comment from: Danny
Those parts of the chart are not configurable in the plugin. You're not missing anything. In the next version we can give more control over that. Until then you can read up on php swf charts and edit the plugin file to make that look how you want.

05/09/07 @ 19:07
Ok, thanks. I'll do that, then. Great plugin. :)

Another idea:
It'd be nice if it was possible, when creating a new poll, to select one or more blogs that the poll will be displayed at. I for exempla have three 'blogs' (well, two + one showing both) and in some cases I'd like the poll to be displayed on two of them, while in other cases I want a poll to be displayed only on one (or on all).

cheers / W
05/10/07 @ 11:42
Wow! Great plugin! Works better than I could ever hope for.
05/14/07 @ 09:38
I am trying to set up the archive page for this plug-in, but here's where I'm having trouble:

This is what I'm told to do in the instructions:

You can add a link that lets you see all of the old polls, but it requires one more edit to the _main.php file. Find the part of the file says "switch( $disp )", and add one more case to the bottom of that list

There seems to be no "switch( $disp )" in the _main.php file, neither in the one my skin uses nor the original one.

Where exactly am I suposed to create this case?
05/21/07 @ 07:00
In the newer versions of b2evo the switch has been moved into /skins/

05/21/07 @ 09:18
"switch( $disp )" does not appear in either. And if I add the case into that file, my whole sidebard disappears and I get this error at the bottom of my page:

Parse error: syntax error, unexpected T_CASE in /home/andrihug/public_html/skins/ on line 43

I am using version 1.9.3 of b2evo...
05/21/07 @ 09:55
Find a section of code that looks like this :

if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

if( $disp != 'posts' && $disp != 'single' )
{ // We must display a sub template:

and change it to :

if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

if( $disp == 'pollarchives' )
// this includes the poll archives if requested
echo '<div class="bPost">';
$Plugins->call_by_code( 'democrcy', array( 'display' => 'archives' )
echo '</div>';
if( $disp != 'posts' && $disp != 'single' )
{ // We must display a sub template:

05/21/07 @ 10:51
Well, that did solve the problem I had with the archives page not displaying. But there is more trouble still. Take a look at the errors I get now on the archives page:

What to do, what to do...?
05/21/07 @ 11:39
hmmm, try changing this section of code ( approx line 959 ) :-

// The archiving function
function jal_democracy_archives ( $params ) {
global $DB, $jal_graph_from_total, $blog;

$where = "WHERE active = '0'";
$where .= ($params['allblogs']) ? "" : " AND blog_id = '{$blog}'";

to :

// The archiving function
function jal_democracy_archives ( $params ) {
global $DB, $jal_graph_from_total, $blog, $cookie;

$where = "WHERE active = '0'";
$where .= ( empty( $params['allblogs']) ? "" : " AND blog_id = '{$blog}'" );


Ooops, looks like you also need to change this code ( line 1024 ) :
if ($add_sup) echo "<br /><small><sup>1</sup> = Added by a guest</small>";

to :

if ( !empty( $add_sup ) ) echo "<br /><small><sup>1</sup> = Added by a guest</small>";
05/21/07 @ 12:01
Yes sir, most excellent. Thank you ever so much for your help! :)
05/21/07 @ 12:40
Comment from: farhad
I'm getting the following error and can't figure out why... any ideas?

Notice: Trying to get property of non-object in ..:\..\public_html\plugins\democracy_plugin\_democracy.plugin.php on line 448

Notice: Trying to get property of non-object in ..:\..\public_html\plugins\democracy_plugin\_democracy.plugin.php on line 465
06/15/07 @ 17:14
Comment from: Danny
Are you using the most up to date version of the plugin? It was updated in May. If not, download the current version and try it.
06/15/07 @ 17:20
Comment from: farhad
jast the same error in v1.5.3 but in diffrent lins.......
06/16/07 @ 15:56
Comment from: Joel
I've gotten the same error as farhad. It occured when all existing polls are deactivated. This leaves the script nothing to call for display. At least, I think that's what is happening. Anyone else confirm?
07/30/07 @ 17:08
Comment from: Joel
I've discovered the error 'Notice: Trying to get property of non-object in...' can be cleared easily by adding the following line of code at the top of the php code in the _democracy.plugin.php file.


It doesn't fix the error but hides it. The plugin works fine and it seems the error can be ignored. Please correct me if I am mistaken about this.

07/31/07 @ 18:01
Comment from: Danny
A notice is not an error and can be safely ignored.
07/31/07 @ 18:12
Comment from: LHaase
I am not sure what it is that I am either doing wrong or not doing but I cannot get the cast votes to display on the main blog page nor any link to view the pie chart.

I have gone over all the posts here and on b2evolution's site and nothing seems to address this other than a vague reference to reading up on php swf and enabling javascript.

Any suggestions/ideas would be appreciated.

I am running Win XP home and not sure what my PHP version is. I use Yahoo!'s web server, which may be the problem itself as they do limit things that basic web hosting can use.
08/26/07 @ 11:35
Comment from: Paolo
I found some serious problems with SEO (latest version 1.5.3 on b2evolution 1.10.2).

See how this issue affected original plugin too:

And fix annuncement in release notes here:

Is it possible to fix it?
09/14/07 @ 00:57
Comment from: zerv

i'd like to make this plugin work with the latest 2.0 alpha 1
i looked at the given code to add :

call_by_code( 'democrcy', array() ); ?>

in the sidebar since that's where i'd like it.

And i get the following Notices (and making the ReportError to 0 doesnt solve anything).

Notice: Trying to get property of non-object in C:\Program Files\EasyPHP 2.0b1\www\b2evolution\blogs\plugins\democracy_plugin\_democracy.plugin.php on line 456

Notice: Trying to get property of non-object in C:\Program Files\EasyPHP 2.0b1\www\b2evolution\blogs\plugins\democracy_plugin\_democracy.plugin.php on line 473

It doesn't display anything at all beside those 2 messages, even if i try uncheck "Display Piechart"

Anyone has an answer, i'm using the latest version of democracy.


09/19/07 @ 00:13
Comment from: hari
How do you add the poll archives in b2evolution 2.x? I cannot find the necessary code to edit since the themeing system has changed.
02/08/08 @ 02:49
Comment from: TITSSN

I just installed this sweet plugin but getting some code errors on the blog.

";s:7:"after_q";s:9:"";s:4:"sort";b:1;s:4:"blog";s:1:"1";s:12:"archive_link";b:0;s:3:"gft";b:1;s:3:"gct";s:4:"#06c";s:3:"gcb";s:4:"#05a";s:7:"poll_id";i:0;}' />
Notice: unserialize() [function.unserialize]: Error at offset 1017 of 1027 bytes in /blogs/plugins/democracy_plugin/_democracy.plugin.php on line 697

Any suggestions on a fix?

Please advise.

Thank you,

02/09/08 @ 23:57
Heya again...

I have a suggestion, could there be a "global" poll option? These will be useful for polls that concerns, well, all blogs on a particular b2evo install.

Or maybe, instead of a "global" option, a "checkbox" on where the poll will appear, and any votes voted on any of those blogs are computed together.
04/07/08 @ 10:06
Comment from: Lance
Like Laibcoms (04/07/08) I would like to have my polls appear globally across my multi-blog pages without the need to enter the poll on every page. Is this possible?
05/25/08 @ 07:30
Comment from: katasun
Just installed the latest version for testing and without any problems, very plugin -- well done
07/24/08 @ 11:33
Moi` cac' ban ghe' tham blog cua? minh` hay lam do ^^
Welcome to my blogweb !
You can't visit myblog.
Thanks you !
See you again,
08/25/08 @ 14:07
Comment from: rich
I tested Democracy 2.2.0. I like it a lot. The only issue I have is with the pie chart. When I click on the pie chart, it goes to this link

Is there any way to disable it?
09/27/08 @ 09:44
Comment from: stjep
Great plugin!
I need to show the polls only to registered users of b2evolution blog.
how is it possible?
10/01/08 @ 09:14
Comment from: Brenda Bell
Nice plugin, but I can't figure out how to make the pie-chart work. When I enable the pie-chart, I get an error in my browser log saying "chart.txt" not found. I tried copying the chart.txt to skins/pixelgreen, but it didn't help. Without charts.txt, I get what looks like a sample chart that graphs the values 2002, 2003 and 2004 -- those values are totally unrelated to my poll.

What do I need to do to enable pie charts?

10/31/08 @ 02:01
Comment from: Na
I've just recently installed the Democracy plugin on my site. It works fine, people were voting, but now I get an error when I try to view the results:

Fatal error: Call to a member function get() on a non-object in public_html/plugins/democracy_plugin/_democracy.plugin.php on line 945

It's the latest version of the plugin...

Thanks for the help!

02/03/09 @ 08:34
Comment from: Marc G
I would like to also request, like stjep, a way to make a post available only to registered users of the blog, to keep it relevant to my specific users and not open to the general public. Is there any way the poll can be made to show in a protected post, for example? I LOVE the plugin! Thanks for all you did to bring it to b2evo!
02/27/09 @ 00:17
Comment from: Marge
hello, I am getting the same Fatal error whenever someone votes.
02/27/09 @ 12:31
I'd like to add the poll archives page to my blog, but I can't figure out where the code is to manipulate. Any chance you could post where to edit in 2.4.6?

Thanks! I love the plugin!

03/17/09 @ 03:23
Comment from: Ross
It would be great if the poll admin page showed the actual vote count for each possible answer rather than just the total votes and the winning answer. I'd like to be able to look back and see if something won 51% of the vote or 88% of the vote, rather than just seeing that it won.
05/06/09 @ 15:14
Comment from: Andy
Just like the person who left a comment on the 0/02/09 @ 08:34 I have also jus installed the latest version on the Democracy plugin on my site and when using Firefox I get the same Fatal error message "Fatal error: Call to a member function get() on a non-object in public_html/plugins/democracy_plugin/_democracy.plugin.php on line 945" when someone tries to view the results. IE works fine!

Can anyone help?


06/29/09 @ 11:51
Comment from: Mo
I get this message:

Fatal error: Call to undefined function: drawchart() in /usr/local/pem/vhosts/207497/webspace/httpdocs/plugins/democracy_plugin/_democracy.plugin.php on line 869

Any ideas?
10/16/09 @ 23:46
Comment from: Denz
cracking plugin, it is just a shame it doesnt work! b2 3.1 - evocamp template - sidebar poll all is fine, showing up and then allowing a vote, no problems, but three of my users on three seperate computers with three ip addresses have voted on the poll, they all are only seeing their own vote and not a single vote of the others. plus in my dashboard and on my webpage, all i see is one vote. any ideas would be welcome as this could be a cracking plugin
10/30/09 @ 18:51
Comment from: brahm
at line we have:


but I get this error msg:

Fatal error: Call to undefined function DrawChart() in _democracy.plugin.php on line 869

any help is appreciated!
11/05/09 @ 00:18
Comment from: justin
Just put it on 3.3.3 and it seems to work fine (note: not enabling pie chart functionality!)
12/30/09 @ 14:38

Comments are closed for this post.