The accepted answer on How to limit a user to one vote when using Fivestar? doesn't work for me, but the author hasn't provided a solution yet, so I felt this is worth a new question.
My goal is exactly the same as the one in the article mentioned above: I'd like to hide the Fivestar rating field (called field_stars) in the comment form when a user comments on a node on which he/she's already commented.
Is there another solution (for example with the Rules and Flags modules)?
Edit: I already have a flag called Commented on my site and a rule that flags a node on behalf of the commentator when someone commented on it (which works perfectly). I'd really like to use it to fix this problem. I tried something, based on the information I found here:
function hiderating_form_alter(&$form, &$form_state, $form_id) {
global $user;
$flag = flag_get_flag('commented') or die('no "commented" flag defined');
if ($form_id == "comment_node_stuff_form") {
if ($form['#node']->uid == $user->uid OR $flag->is_flagged($form['#node']->uid, $user->uid)) {
unset($form['field_stars']);
}
}
}
Unfortunately, it doesn't change anything (I don't get any errors either).