Hook to allow modules to override badges (patch included)
davidc - April 25, 2009 - 17:43
| Project: | User Badges |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
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);
}
}
?>| Attachment | Size |
|---|---|
| user_badges_hook.patch.txt | 664 bytes |

#1
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.