A user can now vote on his/her own nodes and comments. In some cases, this opportunity should be avoided, see e.g. the voting system on stackoverflow.com (or any members of the Stack Exchange family).
Could you provide a field based setting (see #1295574: Remove vud_{node,comment,term} modules in favour of vud_field) not to let a user vote on his/her own node/comment?

Thank you very much in advance!

Comments

marvil07’s picture

Category: feature » support
Status: Active » Fixed

That is currently not possible via a setting option, but it is possible, in fact, a hook was added some time ago thinking in that use case. See vud.api.php for details on the example code (which solves your problem).

Sk8erPeter’s picture

Status: Fixed » Active
StatusFileSize
new167.85 KB
new78.71 KB

marvil07, thanks for your quick response!
I tested it (after setting the correct permissions) with the shown example code in my custom module (after clearing cache), denying access to all the users except the administrator with uid 1 (this is good for testing):

function testmodule_vud_access($perm, $entity_type, $entity_id, $value, $tag, $account) {
  // Denies access for all users other than user 1.
  if ($account->uid != 1) {
    return FALSE;
  }

  return TRUE;
}

This is the result I get when voting with a logged in user:

Access denied alert() window when voting

I should just get a normal error message via alert() or a regular message next to the voting arrows, not the whole page's source code.
Why is that?
Thanks in advance!

marvil07’s picture

Status: Active » Fixed

I have opened another issue for the problem mentioned: #1895594: Custom hook_vud_access() is producing an error

I think the original question on this issue is already solved, so closing it for now.

PS: When you use vud_field, you do not need vud_node, vud_comment or vud_term; actually they are broken now on D7 version and as you know will be removed.

Sk8erPeter’s picture

Thanks for your feedback! I subscribed to the other issue.

PS: When you use vud_field, you do not need vud_node, vud_comment or vud_term; actually they are broken now on D7 version and as you know will be removed.

Yes, I experienced that the other submodules cause a problem on D7. ;)
I think the new vud_field is a much better and much more flexible approach, so it's a great initiative. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mermemladeK’s picture

Status: Closed (fixed) » Active

Hello guys,
Could I call the hook_vud_access from my theme template.php?
I basically want to do the same without creating a new module. Is this possible? What code should I write?
Thank you

mermemladeK’s picture

Another question is:
This hook is basically acting after the author votes his node/comment. Wouldn't it be way nice to simply disable the widget so that the user cannot vote in the first place? Am I saying non sense?

wfragakis’s picture

Issue summary: View changes

Another (very late to the party) request to keep users from voting on their own nodes and comments yet still view the results.