How to force Drupal users into answering a poll

<p>Here, the poll is hardcoded at <tt>node/38566</tt> and the patch applies to index.php in the root of Drupal installation.</p>

<p>Tested on Drupal 6.14, but shall work on many other versions as well.</p>

{syntaxhighlighter brush:diff}
--- index-original.php 2007-12-26 09:46:48.000000000 +0100
+++ index.php 2009-11-23 16:12:11.000000000 +0100
@@ -33,6 +33,12 @@
}
elseif (isset($return)) {
// Print any value (including an empty string) except NULL or undefined:
+ global $user;
+ $result = db_fetch_object(db_query('SELECT nid FROM {poll_votes} WHERE nid = 38566 AND uid = %d', $user->uid));
+ if ($user->uid > 0 && !$result && $_GET['q'] != 'node/38566') {
+ drupal_goto('node/38566', NULL, NULL, 301);
+ }
+
print theme('page', $return);
}
{/syntaxhighlighter}

Tags: