On youtube, only connected users can vote, and when a user is not connected he gets the java script message "Log in to rate".

Is it possible to have this behavior with five star ?

Thanks

Comments

julma’s picture

Title: "Youtube like" behavior for non connected user » I should have named this issue "log in to rate it" message for non connected user

Youtube is still a good example of this feature.

julma’s picture

Title: I should have named this issue "log in to rate it" message for non connected user » "log in to rate it" message for non connected user
julma’s picture

Category: support » feature
quicksketch’s picture

This behavior is possible, but can't really be implemented by default. The reason being it's possible to have multiple roles, and even if the user was logged in they still couldn't vote. So we can't make that message part of the default Fivestar install because it'd be inaccurate in a lot of cases.

Instead, what you can do is over ride the theme_fivestar_static_element() function in your template.php, to make it include this message for your particular site.

/**
 * Display a static fivestar value as stars with a title and description.
 */
function [nameofyourtheme]_fivestar_static_element($value, $title = NULL, $description = NULL) {
  $output .= '
'; $element = array( '#type' => 'item', '#title' => $title, ); $output .= theme('form_element', $element, $value); $output .= '
'. t('Login or register to vote.') .'
'; $output .= '
'; return $output; }
kakarot’s picture

Is this possible in D6?

CinemaSaville’s picture

+1 for D6 implementation.

drupov’s picture

subscribe

thekayra’s picture

The solution provided in #4 works in D6.

dunklea’s picture

How would I modify the above code to make the text a link to my registration page?

Thanks!

TapSkill’s picture

Priority: Normal » Minor
Status: Active » Closed (won't fix)

Just override the display of the fivestar 'block' or widget to add an if statement checking whether or not the user is logged in. This would require custom theming but not much else.

#4 covers some of this, but it doesn't mention any check of user login status. In the example, all widgets display the same message, whether you're logged in or not. You can easily fix this in your template files by adding something like this:

function [nameofyourtheme]_fivestar_static_element($value, $title = NULL, $description = NULL) {
  $output .= '
'; $element = array( '#type' => 'item', '#title' => $title, ); $output .= theme('form_element', $element, $value); if (!$user->uid) { $output .= '
'. t('Login or register to vote.') .'
'; } $output .= '
'; return $output; }

If I'm missing the point, tell me, but otherwise, I consider this issue resolved. Keep in mind, however, that I use D6 and may not understand some limitation of D5. If the above code has anything wrong with it, let me know.