Rules module provides a very powerful infrastructure to define conditionally executed actions based on occurring events. Let’s say a major upgrade to the core Triggers module. It makes a lot of sense to use Rules with Token module to create robust triggers, actions and even workflows without writing a single line of code.

For a recent project, I needed to access the vote value provided by the Voting API and use it with Rules. Strangely enough, when I checked the tokens available to Rules (which is very comprehensive), I realized that the vote value was not available.

Once I figured out that there is no very easy solution for that, I started to look for the easiest way to overcome that inconvenience and further ones. Custom Token module came to my help.

Use the following code to create a custom token (Type=Node) via the Custom Token module. This will make the vote of the logged-in user be available anywhere the regular tokens are available.

global $user;
$criteria = array('content_type' => 'node', 'content_id' => $node->nid, 'uid' => $user->uid);
$user_vote = votingapi_select_single_vote_value($criteria)/10;
return $user_vote;
  1. Thank you for this post. I’ve done everything you wrote, but I can’t get this token visible in Rules. Could you help me?

  2. Hurrah, that’s what I was seeking for, what a data!
    present here at this website, thanks admin of this website.

  3. Truly no matter if someone doesn’t be aware of after that its up to other people that they will help, so here it happens.

  4. If some one wants to be updated with hottest technologies then he must be pay a quick
    visit this site and be up to date all the time.

  5. Don’t worry too much about saving before the stealth course.
    Unless you enjoy murdering people in their sleep, this perk has no lasting value, no
    meaningful stat boost, and no relevance to the main quests.
    The monstrous Kaiju plan to eradicate million of humans and consume humanity’s resources for years
    on end.

    my webpage ultimate robot fighting hack (Chanel)

  6. Il vous est aussi possible d’envoyer des messages emails
    ou encore lancer une discussion privée avec un personne en particulier.

  7. La mayor parte de las personas pueden esperar perder 6, 7 incluso 8 kilos al tiempo que mantienen ( incluso incrementan) la masa muscular, todo ello en 12 semanas.

  8. Si vous buvez du jus d’orange en dehors des repas, finissez votre boite de jus d’orange actuel et n’en rachetez plus.

  9. Individual protoss warriors are unsurpassed in their skills, greatly
    enhanced by tthe combination of technolkgy and formidable psionic strength.

    The Deutschland class German pocket battleships
    were designed to pysh the limits of the Versailles Treaty, which stipulated that the German Navy could possess
    no vessel with a displacement exceeding 10,000 tons. Run up
    andd into the medical bay to drop off the fusion cell.