I want to avoid that users can vote for their own posts, as it happens on Stack Exchange sites. For this, I created the following rule:

  • ON event "User votes on a node", the condition is "execute PHP code" and the code is the following one:

    global $user;
    return $node->uid != $user->uid;

Still, users can vote on their own posts. What should I do?

Using the following code, I get an error message given below.

global $user;


return $node->uid != $user->uid;

enter image description here

  • global dpr($user); dpr($node); dpr($user); return $node->uid != $user->uid; Sep 5, 2013 at 9:34
  • It's global $user. You cannot use a function output in the declaration of a global variable.
    – apaderno
    Sep 5, 2013 at 9:36

1 Answer 1


The rate module allows you to do this in its settings. You have to create a widget for this : admin/structure/rate (just add a new one and then you'll see the option). You will be asked to choose the content type and the position of the widget in the page that you need to define to see the vote system. I didn't try nor with views integration, neither with Drupal 6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.