/*
* Implements hook_node_load
*/
function super_usernames_node_view($node, $view_mode){
$supported_node_types = array('page', 'article', 'blog'); // Supports default content types
if (in_array($node->type, $supported_node_types) {
// query to get number of nodes this user has published
$result = db_query("SELECT count(nid) as nodecount from {node} WHERE uid = %d", $node->uid);
$row = db_fetch_object($result);
$node_count = $row->nodecount; // Easier to read
switch ($node_count){
case $node_count >= 50:
$node->super_username = "God";
break;
case $node_count >= 20:
$node->super_username = "Super Poster";
break;
case $node_count >= 10:
$node->super_username = " Frequent Poster";
break;
case $node_count >= 1: // same as > 0, but who cares...
$node->super_username = "Poster";
break;
case $node_count = 0default:
$node->super_username = "Noobie";
break; // Last break not really needed ...
}
}
}
Now. One last step, you may need to clear the cache for changes to take effect. Devel moduleDevel module makes it easy, or else just use the sql shown on the pageDrush makes it even easier. After this, you should have your super usernames dynamically shown on all the content-types defined in the supported_node_types
array.