This is the discussion page. Back to StarRater

Please leave latest comments here at the top!

Unfortunately another error comes up after voting. I did not try it after my last comment, sorry. :-|

Please have a look e.g. on this page: (will be deleted in a few days). After Voting you will see the error messages! Hans, maybe there is a possibility to fix it short term.

Comment by Holger March 13, 2020, at 08:05 PM

Comment by Holger on March 3rd, 2020

I just found a bug in PHP >7.2 (7.3.11). Hans, please have a look on line 335:

$PageListSortCmp['Rating'] = 'NumericDataCompare($x, $y, "Rating1")'

It leads to an error since V7.2 in every pagelist. Is there a quick fix for that?

Yes, see CustomPagelistSortOrder. Something like this in config.php after the include line should override this:

$PageListSortCmp['Rating'] = 'RatingNumericCompare';
function RatingNumericCompare($x, $y) {
  return NumericDataCompare($x, $y, "Rating1");

Please test and report. --Petko March 03, 2020, at 01:46 PM

Great, thanks Petko! I've now updated the recipe with this change. It works! :-)
Holger March 03, 2020, at 03:00 PM

Comment by Eric P626 on July 23rd, 2018

I am updating my websites with new versions of PM wiki and Star Rater to support the more recent version of PHP for the new server.

The issue I have having is that the text strings for 1star, 2star, 3star, etc appears all 6 as:

InputLabel2($m[1], $m[2])

Is there a quick fix for that?

In the rater.php file, line 328 should look like Markup('label2', [stuff...], "InputLabel2"); without parentheses after InputLabel2 (they were needed in a previous configuration, not anymore). --Petko July 24, 2018, at 04:34 AM

Thanks I replaced:

Markup('label2', '>input', '/\\(:label\\s+(.*?)\\s+(.*?):\\)/i', "InputLabel2(\$m[1], \$m[2])");


Markup('label2', '>input', '/\\(:label\\s+(.*?)\\s+(.*?):\\)/i', "InputLabel2");

and it worked. Thank you

Eric P626, July 28th 2018

Hans - could you organize the download so it could just be dropped into the root pmwiki folder?
Eg., have cookbook folder with cookbook/rater.php, pub/rater/img that holds the images?
There's also an empty, un-documented in the installation instruction folder rater/logs
Later in your notes, it appears that logs can be used for logging, but it's not clear that the folder needs to copied there, or if it will be auto-created. So maybe the entire structure should be
        <image files>
        <empty folder>

And/or update the installation instructions (and make them farm-compatible by default):


  • download rater.zipΔ
  • copy included rater.php to cookbook/ directory
  • copy the rater directory to star images to a pub
  • include the recipe in config.php with

MichaelPaulukonis July 07, 2015, at 09:14 AM

Comment by Eric P626 April 26th 2011, at 8h45 PM

There is a bug with star rater that I have just discovered lately. It's impossible for 2 different user to vote on the same page. In other words, if a page has 1 vote, it refuses all other votes and tell the user they have already voted even if the IP does not match.

Here is a few page example of my website where there is already a vote:

If you try to vote one one of these pages, it will get rejected. The IP address for those pages are currently

4|| and 4||

Do you have any idea what could be creating this problem?

Reply by Eric P626 april 27th 2011

I found the bug. $Rater['authid_voting_restrictions'] was set to true. I first though it had no impact because there is no users on my website. But it seems that if you are not logged in, you would be logged in as guess and guess was allowed 1 vote with the parameter above. So I set it to false and I can now have 2 or more votes.

Setting $Rater['authid_voting_restrictions'] = true; assumes that users are required to login, and only such users can vote. I don't see this is a bug. - HansB April 28, 2011, at 01:46 AM

Comment by CrnB April 18 2011, at 10h06

StarRater doesn't seem to work with SectionEdit - when I put the script on a page, the 'edit this' links of SectionEdit don't appear at all.

Comment by Eric P626 November 16th 2010, at 10h35

I have moved my website on a new server recently and I have a bug where the stars pictures does not show up anymore in the rating. instead it shows "X stars". You can see and example here:

The only thing I did is upgrading from Pmwiki 2.2.0 to 2.2.19.

I tried replacing your line of code at line 101 of script/form.php and it does not work. So do you have an idea of what could be causing this problem. I suspect it cannot find the picture files, but since there is no path to setup, I don't see how the script could be searching for pictures in the wrong directory.

I checked your script version, it's 2009-10-15. So I have the latest script. Thank you for any help.

I think your pub dir url may have changed. You can set the dir url for rater directly in config, before including rater.php, like for instance:

$Rater['imgdirurl'] = '';

or perhaps, if you changed to a farm setup:

$Rater['imgdirurl'] = "$FarmPubDirUrl/rater/img/";

The default is $PubDirUrl/rater/img/ - HansB November 17, 2010, at 02:58 PM

Reply by Eric P626. November 20th, 2010.

It seems that my $FarmPubDirUrl which becomes $PubDirUrl pointed on "" instead of "". Since both sub domain have a Pmwiki site, it was just using the wrong installation files. Thank for the help.

Comment by Utopiah June 06, 2010, at 4:10 PM

Is there a way to display the votes of each user? Id like to display on each profile page who has voted for what in order to create conversations.

You can use a small script in config.php. Include the following lines at the end of your config.php:

#Ratings per author
if ($action == 'rater') {
  $RecentChangesFmt['Ratings.{$Author}'] = '* [[$Group.$Name]]'.'  . . . $CurrentTime - [=$ChangeSummary=]'; 

(you will find the ratings in Ratings.Author)

The $ChangeSummary is defined in:

$Rater['rating_in_summary'] =1;

(see e.g. release notes of StarRater)

If you want to include e.g. the last 5 ratings of any user in the related profile page you can use (:include Ratings.Author lines=5:).

Without any guarantee. ;-) You should wait until Hans has posted his comment - Holger June 07, 2010, at 02:13 PM

Comment by RandyB April 05, 2010, at 1:50 PM

Suggestion: Sometimes opinions change. It would be nice to allow voters to change their votes - i.e. remove the old vote associated with the IP or username, and use the most recent vote instead. The inability to change votes has made me hesitate to use what otherwise would be a very nice recipe for my purposes.

Nice idea, but quite difficult to achieve. The existing script adds new votes to the end of a text file. If a user should be able to change his vote, the script would need to identify the right line for the user, and change or delete that. Also the display would need to give some indication as to what the user had voted before. And all this assumes that there is just one vote per user, but the recipe allows configurations for more than one vote. - So I am afraid that I will not put time into such an extensive upgrade. sorry! - HansB April 05, 2010, at 02:27 PM

Comment by MatthiasGünther November 06, 2009, at 11:35 PM

Hello Hans, is it possible to have only two choices? Can you integrate such a variable for the config.php where you can specify how many choice [min = 2, max = 5] options you want.

Thanks for your respond.

Not really, without going into lots of trouble. The sets of star images are based on 5 stars. So for each different number of stars we would need a different set of images, or rather multiple sets for all the color choices. And this is just one problem. It would also need some substantial code changes I imagine. I don't really want to do such complex extension of this recipe. - HansB November 06, 2009, at 06:17 AM

Okay Hans, I can understand your point. MatthiasGünther November 07, 2009, at 08:38 AM

Comment by Holger October 10, 2009, at 06:43 PM

Hans, I just found 5 errors while checking pages as XHTML 1.0 Transitional. Any page with the StarRater form shows 5 errors.


Positive example (w/o StarRater form):

Any ideas to fix the bug?
Fixed now! (I hope! Sometimes PmWiki markup can throw in validation errors) - HansB October 12, 2009, at 12:10 PM

Thanks Hans, it works :-). You can check it with a click on the links mention above. ;-)
By the way, did you check my hint from August 5 (see following comment)? - Holger October 12, 2009, at 02:50 PM
Done. Thanks for all your tips! HansB October 12, 2009, at 05:27 PM

You welcome! Thank *you* for the great script. :-) By the way, for one of the next versions it could be helpful to have an additional information about the last rating (e.g. a new $FmtPV variable) which is currently only in the pub/rater/logs/ folder stored. On a page with more than one rating it is always time and effort to find out the last rating. But this is a bagatelle and not really important. ;-)
you mean a PV to show which of several rater forms on a page was the latest submitting a rating? The log files don't show that, no time stamps in them. But you can order them by last modified file, which is a very cumbersoe way to check. You mean that? And create a page variable to tell us? - HansB

Yes, I meant this. Your English is definitely better than mine. ;-) What I would like is an additional information about the last rating in RecentChanges. This also could be a SDV in addition to SDV($Rater['summary']. There is no time stamp in pub/rater/logs/ but the last rating (and IP) is stored. It would be easier to find this information in RecentChanges with a proportional rating like 80% for 4 stars. Just an idea, not really important. ;-) - Holger October 14, 2009, at 12:49 PM
Now possible wit hlatest release! I added a config key of $Rater['rating_in_summary'], which is false by default. Set to 1 (true) to enable display of the rating value in RecentChanges summary. The item id is now also always shown (you can give each rater markup a id=name, or a integer number is created automatically as id).
With $Rater['rating_in_summary'] = 1; a RC-summary may look like:
Rated item abc: 5
The rated value is simply the star number. Hope this works for you! - HansB October 14, 2009, at 03:50 PM

Thanks a lot for your support, it works :-) Very good work, Hans. I've done some modifications to make it more flexible for our Wiki, because we do not need the Rater ID in RecentChanges summary. Just my English comments should be revised. <g>. If you want, you can download my version here » (3 new SDV and a modified update part) to check my changes. Perhaps you would like to take on or modify my changes. - Holger October 14, 2009, at 06:05 PM

Thanks, I had a look at it! Why would you want to suppress the id? If there are several raters on a page, I think to show the id is right. If there is only one, then the id does not need to be shown. I think this can be done automatically, without needing a special config setting. The other thing I would like to change is the unit. I think it is sufficient to use

SDV($Rater['rating_in_summary_unit'], XL('stars'));

If no unit is wanted, this is set to ''. - HansB

We have only one id. That was the reason. Your solution looks indeed better, also the SDV definition regarding the rating unit. I just tested the changes you suggested, it works. :-) Hans, thanks again for your support and your fast reply. :-) - Holger October 15, 2009, at 01:45 PM

Comment by Holger August 05, 2009, at 07:50 AM

An additional wish, Hans. Please modify line 138 and 139 in the next version, because after a rating no change is documented in e.g. AllRecentChanges respectively RecentChanges. At present, it is not easy to recognize ratings of anonymous users.

I have carried out the following changes in line 138 and 139:

138: from global $PageTextVarPatterns, $IsPagePosted, $ChangeSummary, $Rater, $EnablePostAuthorRequired;
138: to global $PageTextVarPatterns, $IsPagePosted, $ChangeSummary, $Rater, $EnablePostAuthorRequired, $Author;
139: from $EnablePostAuthorRequired = 0;
139: to If (!$Author && $EnablePostAuthorRequired==1) $Author='anonymous';$EnablePostAuthorRequired = 0;

Please check my changes. It works in my configuration.

Comment by Holger August 02, 2009, at 09:38 AM

Unfortunately the StarRater-Script does not work with PmWiki > V2.2.2. Can you confirm this Hans?

Yes, unfortunately one of the latest PmWiki updates changed the input markup (in forms.php), in a way that StarRater is now crippled. I am raising this issue on the user list. Thanks for the alarm! HansB

What a pity!. Therefore I use the old version 2.2.2 again. I will keep an eye on PITS.01131 and hope that the problem is solved soon to switch over again to the new PmWiki version. Good luck, Hans. Holger

You could change script/forms.php line 103 as I suggest in PITS.01131 until the issue is resolved. Then you'll benefit from the other changes in PmWiki's update.

I just tested the change you suggested. Thanks, it works. :-) By the way, in my sourcecode of the current PmWiki version 2.2.4 line 101 is affected, not line 103. ;-) Holger

thanks, you are right! HansB

Comment by bowler357 July 30, 2009, at 7:16 PM

I love this script. I tried to modify the check IP vote count to work with the User variable but was unsuccessful. Since we use an internal network validating by IP address doesn't help us. Are there any plans to enable user vote checking?

Thanks, Justin

I added a config option $Rater['authid_voting_restrictions']. Set to true if you want voting restrictions based on AuthId rather than IP. $Authd will be checked (needs AuthUser for users to log in with user name). Otherwise $Author will be checked, but this can easily be misused. $Rater['vote_quantity'] sets the number of allowed votes per user or IP (default is 1). This was called $Rater['ip_vote_qty']. - HansB August 01, 2009, at 03:42 PM

Thanks HansB, I love it! - Justin

Comment by Holger May 12, 2009, at 02:53 PM

The recipe is great. I like the way it works but one question. I tried to use the pagelist function to see the page ratings in a clearly arranged list. All ratings from users with edit permission are listed and the ratings are included in the source of the page as well as in the pub/rater/logs/ folder.

Any ratings from users with read permission are just stored in the pub/rater/logs/ folder without any page history. How can I evaluate all ratings, guest ratings included?

Nevertheless great job, great script. :-)

What pagelist markup do you use? - HansB

Hans, thx for your fast reply, :-) my pagelist markup is (:pagelist group=Team list=normal $:Rating1=- order=Rating fmt=#rateridx count=50:). In addition your suggested pagelist template. - Holger

It seems that in your case the rating PTV gets updated only if a user has edit permission. Is that the case? The pagelist only accesses the rating PTVs, not the rating log files. But the rater script does/should update the rater PTV even when there is no edit permission for the user. Only read permission is required. That's how it works for me. - HansB

You are right. The rating PTV gets updated only if a user has edit permission. Unfortunately the rater script does not update the PTV respectively the affected page when there is no edit permission. Thats the problem. With edit permission there is an entry with e.g. (:Rating1: 100:) in the page history, w/o there is no. All ratings from users with read permission are just stored in the pub/rater/logs/ folder without any page history. By the way, UserAuth2 is installed for the authorization. Could this be the reason? Holger

I know nothing about UserAuth2. How does rater work if you don't use UserAuth2? Two other tests you could try is changing in rater.php in function RaterUpdatePTV in the second line (ca. line 131 of the script) 1. 'false' to true', which should pop open the login form if a user is not authorised to read the page; and 2. change 'read' to 'ALWAYS', which will allow any user to update th erater PTV on th epage, even if they have no read permission. Frankly, both these measures should not be necessary, but perhaps they shed some light on a possible conflicting permission settings via UserAuth2. But i am just guessing. - HansB

Hans, I am totally surprised because after the installation of an other recipe called WhosWhere yesterday evening, all problems are solved. Currently I do not know why, but it must have to do with the definition of a variable within the new script. I will try to find out the reason at the weekend and there the matter rests for the moment. You'll here from me asap. - Holger

I just found the reason for the problem I mentioned above. :-) One of the EditVariables named $EnablePostAuthorRequired was it. When I change $EnablePostAuthorRequired in config.php from 1 to 0 the rating PTV gets updated also from users w/o edit permission. I am not sure if this is important for your next update but I think it could be helpful. ;-) Hans, thx for your support and enjoy your weekend. Holger

That would indeed interfer with the rater PTV update. Can you please test with the following change to rater.php:
add to function RaterUpdatePTV after the global declarations:

$EnablePostAuthorRequired = 0;

and add the variable $EnablePostAuthorRequired to the global declarations. I think this would be the right update for rater.php - HansB

I just tested the modification you suggested. It works. :-) This would be a helpful update for the next version of rater.php especially for all users with $EnablePostAuthorRequired=1. Thx again Hans. - Holger

Great, thanks! I've now updated the recipe with this change. - HansB May 16, 2009, at 02:41 AM

Excuse me Hans, unfortunately it does not works. Another recipe has influenced the function. Maybe I've found a different solution in function RaterUpdatePTV.

  global $PageTextVarPatterns, $IsPagePosted, $ChangeSummary, $Rater, $Author;
  If (!$Author && $EnablePostAuthorRequired==1){$Author='anonymous';}

Now It works with my current configuration. Sorry, it was my mistake. Holger May 18, 2009, at 01:22 PM

Thanks, that looks indeed better. I updated the script accordingly. - HansB May 19, 2009, at 06:30 AM

I just found an other potential failure. If the page is not exist, a 404 error page for not-existent pages will generated (Site.PageNotFound). The problem is, you can rate the not existing page and a new page will generate only with the rating. A first workaround could be to modify line 153:

 from $IsPagePosted = UpdatePage 
 to   If (file_exists($pagename)) $IsPagePosted = UpdatePage($pagename, $page, $new);

In addition the text message below should inform the visitor about like

 SDV($Rater['not_existing_page'], "$[You have selected a not-existent page.]");

But currently I do not know which php code must change in addition. Please check the source code. Holger June 06, 2009, at 03:54 PM

Any ideas? Holger July 05, 2009, at 06:33 AM

I've now changed the rater.php code so no rater will be shown on non-existing pages. - HansB July 06, 2009, at 05:06 AM

Thanks a lot, Hans. It works. :-) Holger July 06, 2009, at 04:19 PM

Hi !

I tried to use this great rating system since two days without any result. I tried many things, but I always get the following message : Fatal error: Call to undefined function CondAuth() in .../cookbook/rater.php on line 67 when I click on the rate button. I don't really understand why... I checked my config file etc but I don't really now how to change. If anyone can help me ! Thanks in advance.

You need to upgrade to PmWiki version 2.2 or later. - HansB

Comment by Radu January 20, 2009, at 07:17 AM

The recipe is great! The only thing I would change is the color selection... Normally green is the best and red the lowest, so I would go for green, blue, purple, yellow, orange, red

The color is not actually changing with the rating value. By default you get yellow stars. But one can choose to have green stars or red stars etc. Sorry my little example pic may confuse this, as it also shows the various types of stars. Also: the rendered rater markup will just show one image in HTML. - HansB January 20, 2009, at 09:32 AM

Below are my opinions/suggestions about implementing the star rater for any multidimensional use, in this case for rating recipes in the Cookbook.

Rating is a great idea as a quick, unidimensional measure of fitness to a particular goal.

For example, You know the category 'ToEdit' or some such that was used every now and then on the documentation pages? Replace that with a star system and you get a prioritized list for working on the docs rather than a flat list in the ToEdit category.

But opening a large voting system to a community is tough on resources and will limit the meaningfulness of the system because everyone tends to use different dimensions in voting (remember, we all have different goals in using the wiki and different levels of sophistication), and not everyone can be expected to test and rate each recipe. Also, if 5 users vote on one recipe and another two (different) people on another recipe, how can we compare the two values? Apples and oranges. On big sites with millions of users you tend to get a statistical consensus, especially when the number of votes is recorded and a mechanism exists for weeding out duplicate votes (which is not the case on

I suggest that if this is implemented, only the site managers to have access to voting, so that a balanced, consistent measure can be applied.

Also, I would make the recipe multidimensional (as many sites came to do it): we could consider the need of values for: number of downloads (self-descriptive, easiest to implement), which can be clarified by the following two measures number of uses (# or list of people who are done testing actually use the page/recipe in their wiki or farms; this is more useful, but would require a mechanism for the users to be contacted periodically to confirm continued use) interest (# or list of people interested in the recipe but who did not yet implement it; see above for keeping the number/list up to date)

Then a few starred dimensions: documentation (how well is described) portability (does it work on all platforms or only some?) features (how well does it cover the intended targeted function) functional (how well does it work, are there any bugs, etc) popularity (this can be left open for everyone who passes by to vote on)

Now, I do feel that this is a lot of data to maintain, which is why I would implement it as a separate page (i.e. RecipeVotes, e.g ABCMusicVotes), and all those variables can be condensed by a weighted average of some sort, into a single one to be displayed in the recipe page summary, with a link to the Votes page.

<star image> (<actual weighted value in a %.2 format>) e.g. *** (2.78)

That way, the one value will at least be meaningful :)

Cheers, Radu

Talk page for the StarRater recipe (users).