How would I check to see if a user has a given badge?
GabrielGadfly - March 31, 2009 - 22:58
| Project: | User Badges |
| Version: | 5.x-1.4 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I want to set up a few pages that award a badge to a user when that user views the page. The code would have three parts:
Check if the user doesn't already have the badge.
If they don't have the badge, give it to them.
Print a message telling them they've been awarded the badge.
Else, do nothing.
I can handle the part of the PHP code that awards the badge and prints the award message, but I'm not sure what to put in my if statement (I'm a rookie at PHP..still learning). Any help with this would be appreciated.

#1
Check the $user->badges or $account->badges array.
It's even better if you upgrade to D6. Then you can use the Rules module to do the whole thin for you without any PHP code at all!
Also, this module is phasing out D5 support.
#2
Automatically closed -- issue fixed for 2 weeks with no activity.