Is it already possible to automatically assign users certain roles when they sign up for a node and to remove roles when they cancel their signups?

If possible - how to do it? If not possible, I would file it under feature request and would like to sponsor it to be implemented.

Thanks!

Comments

dww’s picture

Category: support » feature

Not possible through the UI.

I'd only implement something like this as a separate module, since there's no way I'd want to bloat the main signup module with something like this.

Luckily, there are hooks invoked whenever a user signs-up or cancels, so it should be pretty easy to implement this in another module.

giorgio79’s picture

Version: 5.x-2.4 » 6.x-2.x-dev

If the module would expose an event to Rules, assigning a role would be a piece of cake with that module. :)

Any plans for that?

ezra-g’s picture

I marked #812040: Role assignment to a user once the "Mark signup attended" action is fired. as a duplicate of this. In that issue, I mistakenly reported that we have actions/trigger integration for when a signup is created.

In general, this seems like a pretty common feature. #901678: Assign role to signed up users is a request for it as well.

I see two ways of approaching this feature:

A) With Actions: We could add a trigger for when a signup is created/cancelled and fix up http://drupal.org/project/user_role_actions so that it actually works.

B) Add a configurable option to Signup allowing admins to specify which role(s) should be granted/removed upon signup creation/cancellation. We could make this drupal_alterable with the $node and $account objects, so other modules can alter the way this works based on things like existing user roles or specific nids (or anything else). I see this setting being site-wide initally, though we could later make it nid or node type specific to facilitate a separation between "regular" events and "special" ones that should result in a role being created.

ezra-g’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

Here's a super simple signup_roles module that should live in signup/modules :) .

ezra-g’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
greggles’s picture

StatusFileSize
new2.33 KB

This mostly looks good to me.

There was a typo in the variable name in the form vs. the variable_gets. I've made this consistent.
It doesn't make sense to show "authenticated user" role as one that can be granted, and this didn't provide good help text if there weren't any roles beyond authenticated. So...I fixed that.

There was some trailing whitespace that my editor removed.

The attached patch was created from a locally created git repository, so it should apply, but maybe not...

Looks great to me!

After committing this, I suggest creating a component for it in this issue queue so that feature requests/bugs can be filed appropriately. One obvious feature seems like making this work on a per-event basis (i.e. the configuration for it would be shown on the node and stored per node, rather than being site wide). This does meet a good basic use case, though, so it seems worth adding in its current form.

ezra-g’s picture

StatusFileSize
new2.64 KB

Great points, thanks.

I've re-uploaded the module with changes by greggles and tested.

I think this is RTBC but would love to get another +1 first.

sarahjean’s picture

Hi, I'm using Ubercart and the signup integration module on my signup site, to charge for registrations.

I installed and tested out the signup_roles_1.zip module and choose one of the custom roles on my test site on the admin/settings/signup page.

I tried it out, (added event to cart and checked out) and I am getting an error:

warning: Invalid argument supplied for foreach() in /sitepath/sites/all/modules/uc_signup/uc_signup.module on line 661.

The role that I choose doesn't get applied to the users who signed up/were signed up by other users.

Here's some of my site specs:
Drupal core 6.19
Conference Organizing Distribution Support Modules 6.x-1.0-alpha1
Signup 6.x-1.0-rc6
Signup Integration for Ubercart 6.x-1.0-beta5
Ubercart 6.x-2.4

Also, on a separate note, I realize this may be a future development thing, but are there plans for the role that is applied to vary based on what event was signed up for?

Thanks for working on this feature!

greggles’s picture

coltrane’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed the code and tested the module and it looks great.

ezra-g’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the reviews! This is committed.
http://drupal.org/cvs?commit=436184

ezra-g’s picture

Title: Automatically assinging and removing roles when users signup oder cancel signups? » Automatically assign roles when users sign up to events

Status: Fixed » Closed (fixed)

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

ezra-g’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Closed (fixed) » Patch (to be ported)