Support Forum
We are using the Post Rating plugin (with stars).
We would like to introduce an intermediate step into the rating process where people will have to confirm their rating before it is applied to the post.
I've looked at the actions and hooks, and don't see anything that would seem to help us insert this extra step.
Do you know whether this has been done before, or can you offer any bright ideas as to how we can accomplish this?
I don't mind digging into the plugin's code, but would prefer not to...
Thanks,
David
afraid there is no option for enabling something like this... however, I think you can use one of our hooks to do it... namely this one:
sph_PostIndexRatePost
its actually a filter and contains the entire post rating html before being displayed... so you could filter it and add a javascript confirmation... over simplifying, but look for the html output by this code:
$link = 'style="cursor: pointer;" onclick="javascript:spRatingRatePost(\''.$postid.'\', \''.$site.'\', 2);" onmouseover="spRatingStarHover(\''.$postid.'\', \''.$x.'\', \''.$overimg.'\')" onmouseout="spRatingStarUnhover(\''.$postid.'\', \''.$intrating.'\', \''.$onimg.'\', \''.$offimg.'\')" ';
and add a javascript confirm statement prior to the javascript:spRatingRatePost portion of the onclick attribute...
Visit Cruise Talk Central and Mr Papa's World
Thanks for the suggestion.
I'm having a bit of trouble with using the filter.
$out = apply_filters(‘sph_PostIndexRatePost’, $out, $a);
Is the $a variable required? Could you explain the usage here, or (even better) show me a simple example?
I got the confirmation to work by editing the plugin file, but obviously would prefer not to have to modify that page each time we upgrade...
Thanks,
David
its a wp function... see: http://codex.wordpress.org/Fun.....ly_filters
basically, you are passed $out and a bunch of options context data... you must return the $out value modified or not... the trailing arguments are provided for your use if needed...
so something like:
add_filter('sph_PostIndexRatePost', 'my_post_rating'); function my_post_rating($out) { $out = str_replcae('javascript:spRatingRatePost(', 'javascript:if(confirm("Do you want to rate?")) spRatingRatePost(', $out); }
Now, that is untested, but hopefully you get the idea... search the html in the $out variable being filtered and replace it with the javascript confirm added...
Visit Cruise Talk Central and Mr Papa's World
1 Guest(s)