I've this working with User Badges (http://drupal.org/project/user_badges), if someones wants the patch I can post it...

introfini

CommentFileSizeAuthor
#15 rolesignup.module.patch880 bytesintrofini

Comments

WISEOZ’s picture

Do you mean that you have this working with Role Signup so that a user gets a certain badge based on the role they are being assigned to. Can you explain what your patch does? I might be interested. Thanks!

introfini’s picture

It does exactly that, when the user is creating is account it gets the badge associated with the role.

introfini

WISEOZ’s picture

I'm certainly interested! I'm looking to have the "user badge" displayed for one particular role everywhere their Username appears. So, it sounds like this would at least create the association between the user and the role and then I'd just need to figure out how to marry the two together in the layout. Thanks!

introfini’s picture

User badges does that on is own. Check it out and give it a try...

WISEOZ’s picture

I TOTALLY missed that! Thanks so much for pointing out the obvious. Duh!

Anyhow, now User Badges does everything I need expect it includes the badge as a new section in the profile. Do you know how I'd go about associating the badge display to the Username wherever it's shown. I've seen this on a few sites that use User Badges but can't quite figure this one out.

introfini’s picture

On the theme page put print user_badges_for_uid($uid); . read the readme.txt

introfini

WISEOZ’s picture

I gave this a shot a few different ways based on the README but it wasn't quite what I was looking for. I'm still looking for the user badge to appear next to the Username on pages, forums, and whatnot. I guess what I'm looking for may be more complicated. Thanks for your continued advice.

introfini’s picture

you have to add that code to the theme or else it will not work

WISEOZ’s picture

I had added this code to the page.tpl.php within my themes directory. Is that what you meant?

introfini’s picture

Display badges
==============
To display user badges in your theme use :

print user_badges_for_uid($uid);

Note: $uid means 'a user id' here, not the literal use of $uid. Most people will use
the uid of the node ($node->uid) or comment ($comment->uid) author.

--------

so the best place is node.tpl.php and comment.tpl.php

WISEOZ’s picture

Adding it to node.tpl.php did the trick! Thanks so much for hanging in with me.

hdornier’s picture

I'm very interested by this patch. Could you post it, please.

thank you very much

introfini’s picture

Hi,

You should substitute the function rolesignup_user() for this one:

function rolesignup_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'insert':
    $roles = user_roles(1,'register for role');
    if ($roles[$_SESSION['role']]) {
      db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $_SESSION['role']);
      if (module_exists('user_badges')) {
        $roles = user_badges_get_roles();
        $rid = $_SESSION['role'];
        // if this role has a badge
        if (key_exists($rid, $roles)){
          user_badges_user_add_badge($account->uid, $roles[$rid], 'role');
        }
      }
    }
  }
}

I can send you a diff file if you prefer.

introfini

cyberswat’s picture

Assigned: Unassigned » cyberswat

would appreciate it if you could post a patch to this issue. Thanks

introfini’s picture

StatusFileSize
new880 bytes

hi,

here it is...

thanks,
introfini

cyberswat’s picture

Status: Active » Needs review
cyberswat’s picture

Thanks introfini ... I looked into this and I believe that you will get this functionality with the dev version of http://drupal.org/project/autoassignrole ... the original version of Role Signup did not use Drupal's hooks properly

cyberswat’s picture

Status: Needs review » Fixed

and I hit submit to quick ... I installed the user badge module and I think it's working correctly with the autoassign module ... could you verify? http://drupal.org/project/autoassignrole

Anonymous’s picture

Status: Fixed » Closed (fixed)

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