About the author

Photo of sanduhrs
sanduhrs

Drupal User Activity Module

The User Activity Module [1] is a module for the great and flexible Drupal Web Content Management System [2]. It calculates and displays a user's activity index.

The calculation is currently based on 4 factors:

  1. We count the logins a user does. So we can calculate a percentage value based on the user's logins and the maximum login count a user did.
  2. We count all page impressions our users generate and calculate another percenatge value based on the user's pis and the maximum pis a user generated.
  3. We count the nodes the user created and the maximum count of nodes a user created and generate a percentage value.
  4. We count the comments the user created and the maximum count of comments a user created and generate a percentage value.

So we have four percentage values, we sum them up and divide it by 4.
The result is a user's activity index.

The generated activity index will be displayed on the user's profile page per default.
Drupal user profile page with activity-o-meter

Many people customize the user profile layout [3] with a technique described on drupal.org.
With a simple function call you may display a given user's activity-o-meter wherever you want, just do

<?php
 
print theme('user_activity_o_meter', $user->user_activity_index);
?>

And if you additionally want to modify the presentation of the activity-o-meter, you simply add the following code to your theme's template.php (if it doesn't exist, simply create it) and modify it as you like.

<?php
function phptemplate_user_activity_o_meter($index) {
 
$output = '
  <div class="user_activity_o_meter" style="width:100%;height:20px;background-color:#C3D9FF;">
    <div style="width:'
. $index .'%;height:20px;background-color:#6BBA70;color:white;text-align:center;"></div>
    <div style="margin-top:-20px;text-align:center;">'
. $index .'%</div>
  </div>'
;

  return
$output;
}
?>

Weblinks

[1] http://drupal.org/project/user_activity
[2] http://drupal.org
[3] http://drupal.org/node/35728

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Website powered by lovely Drupal · Microformats · XML Feed · Valid XHTML, CSS · No www.