Posted by davidc on April 25, 2009 at 5:43pm
Jump to:
| 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);
}
}
?>| Attachment | Size |
|---|---|
| user_badges_hook.patch.txt | 664 bytes |
Comments
#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.
#2
No update in a year. If you try drupal_alter, please let us know if it works, and maybe a piece of sample code.