I have a custom module I'm writing, part of what I want it to do is create a vote associated with a node, I'm trying to figure out how to call the voting API from my module. I loookd in the documentation but it's a little sparse.
Drupal Creating Votes in Voting API Through Code
2.6k Views Asked by user379468 At
2
There are 2 best solutions below
0
NickOpris
On
Just another example of using this:
function _ept_set_vote($nid, $status, $uid = NULL) {
global $user;
$vote = array(
array(
'entity_type' => 'node',
'value' => 1,
'entity_id' => $nid,
'uid' => (!$uid) ? $user->uid : $uid,
'tag' => $status
)
);
votingapi_set_votes($vote, array());
}
I call it like this:
switch($task_status){
case('start'):
_ept_set_vote($nid, "Start");
break;
case('completed'):
_ept_set_vote($nid, "Completed");
break;
}
Related Questions in API
- SuiteCRM how to retrieve all account related contacts
- how do i submit a pastebin or pastee from an android app and get the url back
- BigCommerce PHP API delete Category which contains products
- Interact with chrome bookmarks outside of extensions
- purchase individual items and subscriptions in the same PayPal REST API transaction
- youtube api v3 insert comments
- Youtube api v3 duration
- Responding to an Office 365 event invite via REST
- Convert youtube video to mp3 using Quick MP3 API
- How to real-time monitor the emails?
- Laravel - Fractal - Using Find() in transformer file- is it correct or can it be done more efficiently?
- return data from a Azure API json
- Accessing Picasa Web API using PHP
- RAML multivalued form parameter
- TestFlight API and stats with as3
Related Questions in DRUPAL
- Drupal access control to custom user profile page
- How to list all child pages of current parent page in drupal 7?
- MariaDB/MySQL all of a sudden crashed and won't restart
- Drupal location module shows only a portion of Gmap on node page
- How to add a select collection type select list to field collection
- Drupal7 modified user login no effect?
- Drupal AngularJS ajax simple ng-repeat update
- Drupal: Access A Field in hook_views_query_alter()
- Drupal Webform : set SCORE on each SELECT Options?
- Register new user as authenitcated user in drupal using xml-rpc
- Drupal domain access auto create content
- How to display sibling pages except current page in drupal 7?
- how to merge entity reference relationship field value
- Drupal print breaks when rendering a region
- All files and folders are not being listed in the imce file browser in Drupal 7
Related Questions in MODULE
- Magento custom block. Can't get block's file
- Undefined is not a function when calling node module
- Why is it bad practice to use from module import *?
- Node.js http.get example
- Perl Module using %EXPORT_TAGS
- Yii, Load a model of a module from the main app controller
- Ocaml unbound type constructor with module
- Drupal location module shows only a portion of Gmap on node page
- phpinfo() uses old version. What am I missing after "make install"?
- Accessing 2 different tables from same controller file
- Do software engineers in general have no idea about Software Architecture Design?
- Class Path entry my.jar does not point to a valid jar for a Class-Path reference
- TypeScript: workaround for relative reference path?
- Python - Can't install modules on mac
- Text file not being imported with module
Related Questions in VOTING
- mysql query to check if user voted
- acts_as_votable using ip address
- Web based election database software
- How to make bootstrap Voting snippet functional, change value in MySQL
- how to allow the user to specify the names and the program will use that names for reporting results?
- How to report the winner in each county and print out bar graph for two candidates' total votes?
- Voting-system wont pass on vote to database
- Designing a Django voting system without using accounts
- How do I execute a vote using the Rails 3 gem 'thumbs_up'?
- Drupal Creating Votes in Voting API Through Code
- Joomla 2.5 not limit one vote per IP address
- How concisely can I represent a permutation of 1024 from 1024?
- Displaying total votes count with thumbs_up
- How would you add weight to a voting system like "thumbs-up" based on time?
- Saving cookies for voting ASP.NET
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Here is an example from a module I wrote a while ago.