Creating this issue to attach a patch I wrote that adds 2 conditional actions to uc_signup. One that can add a set of roles to each user being signed up an one that can remove said set. It aims to be helpful in adding say the 'attendee' role to all users being signed up to an event in COD.

CommentFileSizeAuthor
#4 signup-roles-1321742-4.patch4.43 KBcafuego
#1 1321742-2.patch3.22 KBcafuego

Comments

cafuego’s picture

StatusFileSize
new3.22 KB
cafuego’s picture

Title: Allow roles to be added to using being signed up (uc_role can't do this) » Allow roles to be added to users being signed up (uc_role can't do this)

Fixed issue title.

cafuego’s picture

Status: Active » Needs review
cafuego’s picture

StatusFileSize
new4.43 KB

This time a working version. Check the signups correctly (why do the confirmed and temporary signups API calls have different params?) and cycle through the signed up users correctly. Also write an entry to the order admin log.

ezra-g’s picture

Status: Needs review » Postponed (maintainer needs more info)

Thanks for providing a patch!

However, you can already add user roles to users who purchase signups in 2 ways. Signup includes a signup_roles module, to associate the granting of roles with the creation of a signup, and you can use Ubercart core product features to grant a role when a signup-enabled product is purchased.

Is there a reason why these 2 solutions aren't sufficient?

cafuego’s picture

uc_roles can add a role to the user buying the signup, but that's not always the user being signed up to an event. Eg: managers buying conference attendance for subordinates.

I hadn't even noticed signup_roles to be honest, but just had a look at that, and it looks to add the roles to signups just fine ... but doesn't remove them when the signup is cancelled. Which is not helpful in my use case, where I provide access to content and functionality based on signed-up status... using a role is by far easiest for that.

The CA hooks in uc_signup in the patch can respond to a signup order being cancelled and remove the roles from the affected user(s). Additionally, different roles can be assigned or removed in each CA, so if users want, they can be flexible with role assignments... even add a role if a user is no longer signup up or remove a role when they do sign up.