0

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;

dpr($user);
dpr($node);

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

enter image description here

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

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.

|improve this answer|||||

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.