Upon enabling the module I get this error:

Notice: Undefined index: roles in user_badges_user_presave() (line 315 of /home/accountnamehere/public_html/drupal/sites/all/modules/user_badges/user_badges.module).

CommentFileSizeAuthor
#5 undefined_index-hook_presave.patch1.94 KBSebCorbin

Comments

nevets’s picture

This is because presave is not an appropriate hook work done since the user is not yet defined for new users, the code should be in user_insert() and user_update().

dhlconsult’s picture

in sites/all/modules/user_badges/user_badges.module on line 315 i deleted
function user_badges_user_presave(&$edit, $account, $category) {

and added
function user_badges_user_update(&$edit, $account, $category) {

this is first thing: now it is run at user registration / update.

part two is the problem with saving the role badges. solution was a patch i found somewhere here on drupal (cant find it now...)

also line 299
deleted if (!key_exists($roles[$rid], $account->badges)) {
added if (!@key_exists($roles[$rid], $account->badges)) {

anyways, now it works. one little caveat though: when updating user (for instance blocking) it does not seem to change. however, i can live with that. at least now it works "good enough 'till a fix is there".

you're welcome ;-)

nancydru’s picture

Thanks for your efforts.

imoreno’s picture

This issue still happens with the last dev from 25.6.12.

when a user is logged in he gets this error on the first user page.
While not critical it would be nice if this could be fixed as this error message is not so friendly for a logged-in user..

BR
Itzhak

SebCorbin’s picture

StatusFileSize
new1.94 KB

Can you try the following patch?

imoreno’s picture

Status: Active » Reviewed & tested by the community

Thank you SebCorbin,
with last release from 27.6.12 + patch #5 did the trick for me.
the error is gone.

BR
Itzhak

SebCorbin’s picture

Status: Reviewed & tested by the community » Fixed

Committed!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.