Download & Extend

Hook to allow modules to override badges (patch included)

Project:User Badges
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

I needed the ability to allow modules to add/remove badges. Please find attached a small patch that adds a new "hook_user_badges" that modules may implement to modify the user's badges.

Note that this does not use module_invoke_all, as the first argument must be passed by reference. It uses instead the same method used by user_module_invoke">.

Example use by a module:

<?php
/* Implementation of hook_user_badges */
function goopackage_user_badges(&$badges, $uid)
{
  if (
$uid == 3) {
   
$badges[2] = user_badges_get_badge(2);
  }
}
?>
AttachmentSize
user_badges_hook.patch.txt664 bytes

Comments

#1

Version:master» 6.x-1.x-dev
Status:needs review» needs work

I think drupal_alter() will let you achieve want you want here without hard coding a hook invoking system.

Thanks for the patch!

I'm going to move this onto 6.x or else I'll keep missing it.

#2

Status:needs work» closed (won't fix)

No update in a year. If you try drupal_alter, please let us know if it works, and maybe a piece of sample code.

nobody click here