This module currently throws an error on user creation with OG Invite.

In role_change_notify_user_presave() on line #156 there is a check for $account->uid > 0. But OG Invite only returns:

object(stdClass)#119 (1) {
  ["is_new"]=>
  bool(true)
}

Could there be an extra check on this, like change this:

  if ($account->uid > 0 && array_key_exists('roles', $edit)) {

to this:

  if ($account->is_new == FALSE && $account->uid > 0 && array_key_exists('roles', $edit)) {
CommentFileSizeAuthor
#2 role_change_notity.patch590 bytesHansKuiters
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rfay’s picture

A patch is welcome. I'd also be happy to give you privileges on this module, as I haven't (ever) used it, so it gets no love.

You should also consider using Rules, which gives far more flexibility.

HansKuiters’s picture

Priority: Major » Normal
Status: Active » Needs review
FileSize
590 bytes

Thanks. But I'm no great developer, not that familiar with git and I'm not planning to upgrade to developer status here at Drupal.

Patch is attached.

rfay’s picture

Good enough to make a patch that passes testing the first time... Ready for the big time!

@capono++

rfay’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Needs work
+++ b/role_change_notify.module	2012-11-08 17:27:40.000000000 +0100
@@ -153,7 +153,7 @@ function role_change_notify_form_user_ad
-  if ($account->uid > 0 && array_key_exists('roles', $edit)) {
+  if ($account->is_new == FALSE && $account->uid > 0 && array_key_exists('roles', $edit)) {
     _role_change_notify_update_user($edit, $account, $category);
   }
   return;

I think this would improve it, so it doesn't stumble on various items in the account object being unset:

if (empty($account->is_new) && !empty($account->uid) && array_key...

HansKuiters’s picture

Haha, only thanks to OSX, Terminal and diff.

rfay’s picture

If you're interested... I will happily help you with any git roadblocks you may come across. And there's lots of good info. Most of it is pretty easy. Works great on the mac.