Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here's a D6 version of this.
A very simple module to have a user vote for content automatically as they create it. Have called this module autovote (autovote.module
).
1. Create a directory under modules
named autovote
.
2. Put the following in autovote.module
:
<?php
/**
* Implementation of hook_nodeapi()
*
* Vote on the node as it's saved.
*/
function autovote_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
/* Only vote on database inserts */
if ($op != 'insert') return;
/* Stop anonymous votes - don't if not logged in. */
global $user;
if (!$user->uid) return;
/* Don't vote if not new */
if (!$node->is_new) return;
/* Optionally filter content types - modify as you wish. */
/* Eg. don't vote for anything but images. */
if ($node->type != 'image') return;
/* OK - let's vote */
$votes = array(
'content_id' => $node->nid,
'value' => 100,
);
votingapi_set_votes($votes);
?>
3. Put the following in autovote.info
:
name = Autovote
description = "Have a user automatically vote for content as they create it."
package = Voting
core = "6.x"
version = "6.x-0.1"
4. Visit modules admin page and enable the new module.