Adsense module hack - giving users credit on their user profile

in
The Adsense module allows you (the webmaster) to share revenue with content contributing users. You can assign a percentage to share with users. If you have the referral module installed, you can also give a cut to referring users. On the Killer Aces network, we want to give users credit on their profile pages as well. This requires a little theme hacking. How to give users Adsense credit on their profile page Step 1: Allow customization of the profile page Create a user_profile.tpl.php template file in your theme directory. Here's a basic user profile to get you started. The drupal.org handbook on customizing the user profile has a bunch of handy snippets. You'll need to add the following overriding function in template.php so the newly created user_profile.tpl.php will be used. /** * Catch the theme_profile_profile function, and redirect through the template api */ function phptemplate_user_profile($user, $fields = array()) { return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields)); } Step 2: Force the Adsense module to use the adsense_client_id of your choosing Insert the following code somewhere in user_profile.tpl.php. This overrides the default usage of the site's client id on the profile page. <?php if (module_exist('adsense')) { $uid = $user->uid; static $client; $client = adsense_get_client_id($uid,'blog'); } ?> Note: The above code was for Drupal 4.7. In Drupal 5.x, module_exist() becomes module_exists().

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.
  • No HTML tags allowed

More information about formatting options

luigi