2

I am using Vote Up/Down for voting on nodes. I would like that anonymous users could be see the voting widget, but they should be first redirected to the login page, before they vote. I tried setting the permissions as follows:

  1. use vote up/down on nodes - checked for anonymous user
    When I try to vote as an anonymous user I get the following error.

    An error occurred at /vote/node/1470/-1/vote/helpful/59a7d98542754cb9fd01758fbbe95a3a.

    Error Description: 403: Forbidden

  2. use vote up/down on nodes - checked for anonymous user; view up/down count on nodes - checked for anonymous user
    I still get the same error.

Does anyone know what to do to redirect anonymous user to the login page when they try to vote?

  • where are you seeing this error? Do you have the site set up to login when permission is denied? – Jeremy French May 13 '11 at 15:35
  • i am seeing this error as a popup on a page. and when i am using an anonymous user..i do username/passowrd to login but it does not take me to the login page..it shows the error in a popup.. – ayush May 13 '11 at 16:03
  • The links are firing via ajax, that won't be compatible with login on unregistered. – Jeremy French May 13 '11 at 16:11
  • so i will keep getting the access denied popup ...no ways to solve this?? – ayush May 13 '11 at 16:39
  • if you find a vote module which doesn't use ajax you should be ok. – Jeremy French May 13 '11 at 17:14
1

I have installed the module that you mentioned and got the same error. It seems that even though the Vote Up/Down module allows you to give anonymous users permission to vote, internally, it does not support it and throws the specific error. I suspect - I'm guessing here - that they are using the user id to "save" what the logged-in user voted and when the user id is 0 (which means anonymous) an error is thrown.

Anyway, the way I see it, there are 2 main paths that you can follow in order to get the functionality that you want:

1) Have someone (= a drupal developer) modify the module for you. This way, you will be able to add the functionality, and even submit the changes it to the module's repository.

Pros: you help the community, you get a clean solution (depending on the developer's skill)

Cons: costly (I suspect), takes time, you get bad code and patch the problem (depending on the developer's skill)

2) Get the functionality through theming. Instead of enabling the module for anonymous users, you can just disable it, and through the node-nodetype.tpl.php file you can just show the image of the voting arrows to the anonymous users (you will have to use an if conditional to check if the user is logged in or not) and make the image point to a link like this:

/user/login?destination=/node/$node->id

This way the user will be redirected to the login form and then back to the node, but he will have to press the vote button again.

Pros: easy to implement, theme based solution = minimal interaction with code

Cons: it's really a work-around, not a solution, the user is not actually voting but he thinks he is voting (not really honest :P)

1

If anyone is still wondering about a workaround for this (I sure was)...you have to edit the /ajax-responder.js file, found here: /sites/all/modules/ctools/js/ajax-responder.js. If you View Source on the page(s) that have the vud widget, you'll see it included in your header (included in $scripts).

Here's what I did:

  • Make a duplicate copy of the file just incase.
  • Do a Find for "An error occurred at", and you'll find the alert() line that's causing the obtrusive alert message. Comment it out.
  • Add in a redirect. Exactly what F1234k mentioned (thanks!). The 'path' variable that gets passed into the function includes the node ID (yay!). To get the node id, you need to split up the url (it includes a long ajax call url) to grab the section with the node id (which is in the 3rd section of the url):

    var path_split = path.split("/");
    
    var path_node_id = path_split[3];
    
    window.location = "http://www.site.com/user/login?destination=node/" + path_node_id;
    

Unfortunately this still runs an error on the page and it is just a workaround, but it gets rid of the nasty alert message without having to mess around with too much code!

Also, I did this in 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.