CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Assigning drupal role after event registration.
Pages: [1]

Author Topic: Assigning drupal role after event registration.  (Read 1890 times)

nero

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal 6
  • MySQL version: 5.1.49
  • PHP version: 5.3.3
Assigning drupal role after event registration.
February 24, 2011, 12:36:20 pm
I am currently trying to set up a drupal/CiviCRM site that would serve one main purpose- event registration for short courses my company teaches.  I am still on the fence if CiviCRM is overkill, or if it would be something worth tackling that I would grow into.  Any thoughts/tips on how to accomplish my goal would be appreciated.

First, some background.  Our company is offering paid short courses several times per year.  In drupal, we have created course objects, which have a few different access levels based on roles.  For example, for our spring 2011 computation course, we have a few roles: S2011_Comp_Enrolled, S2011_Comp_Instructor, and S2011_Comp_Admin.   A user on our site without any of these roles is able to see the marketing side of the course- detailed description, testimonials, where it will be held, enrollment fees, link to register, etc.  A user who has the S2011_Comp_Enrolled role also sees links to (and can follow said links) course information reserved for students, e.g.: course materials, course updates, link to reserve hotel rooms at the course rate, etc.  Things we don't want the whole world to see.  _Instructor and _Admin roles have the ability to update content on these pages.

Enter CiviCRM.  I am interested in using CiviCRM to allow paid registration for our courses, directly on our site.  We have merchant/Authorize.net gateway accounts, proper SSL certs, and are all ready to begin taking credit cards online.  I like that CiviCRM would take care of course lists, name badges, etc.. for us.  However, I am having trouble getting everything working together.  My ideal workflow is as follows:

1. We set up a course, and course roles in Drupal.
2. We set up an event in CiviCRM, with proper pricing (early bird special price, academic student price, etc..), that works through our payment gateway.  We are also able to specify a Drupal role to assign students who register (the _Enrolled role created in step 1).
3. A user comes to our site, and after reading the marketing material, goes to register for the course.
4. A form pops up requesting the relevant info from the user: Name, Affiliation, Title, Email, requested Username (if they don't have a drupal acc yet), Billing Address, CC info, Registration type (General or Univ. Student).
5. The CC is charged- if successful, and the user is not logged into Drupal, a new drupal account is created (otherwise the rest is associated with their logged in drupal account).
6. The user is added in CiviCRM as an event registrant.  In addition, their drupal account is given the role specified in step 2.
7. Now the user has access to all of the "top secret" course stuff that only registrants get access to.

I've got much of this working in CiviCRM/Drupal currently.  However, I am having issues with having CiviCRM assign a drupal role upon successful enrollment.  After some conversations in the irc channel, it was suggested I look into using hooks.  I've been reading up, but a couple of questions remain-

1. How would I generate a drop down for the page to build CiviEvents which would allow me to pick an Enrolled role to assign upon registration?  I am assuming that along with a hook to generate this dropdown (though which hook this is, I have no idea), I'd need to add some field to the events database table to track the associated roll?

2. Which hook would I be calling to add the roll upon successful registration?

3. Am I thinking about this the wrong way?  Is there a better way to approach what I want to do?  Any thoughts would be greatly appreciated.

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: Assigning drupal role after event registration.
March 02, 2011, 08:59:38 pm
Hi nero,

Really interesting. Creating generalise Drupal module will be good solution ( I think currently there is no any module is available ).

I think it will be like following -
- On module installation it will create a table in drupal db ( to map event and drupal role configured for that event )
- Module will provide a drop down list on add/edit event page ( event setting page ) , which will list all drupal roles.
   OR may be in drupal admin configuration where we can choose civicrm event and one of the drupal role.
   So that we can select specific role to be given to the participant after successful registration of that event. Mapping will be store in db table.
- After event registration, drupal role configured to that event will be automatically given to that user.

Above looks easy, but need to handle some conditions like,
- User is not logged in and going to create cms account after event registration.
- He is also going to register additional participants.
- What if payment is not suuceesfull or he is registered as a paylater.

Rajan

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Assigning drupal role after event registration.
March 03, 2011, 12:37:39 am
I would consider approaching this differently. Create a small Drupal module to check a person's participation in an event before allowing him access to course materials. Presuming you want this for mutiple courses:

1. In your Drupal node(s) you create a way to store a reference to the relevant CiviEvent--whether it's open text (low tech) or a dropdown of events (high tech).

2. When anyone attempts to view such a node, your custom module first looks to see if they are a participant of the relevant event. This would be if they do not have a role which overrides this, such as Admin. So for non-admin and non-staff etc, the module checks their participation. If it's there, then OK, and if not, then the code denies them access.

The code can know which nodes are restricted via a CCK field or via the node type etc.

I would think this would be simpler.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Assigning drupal role after event registration.
March 03, 2011, 01:54:17 am
So a Smart Group built from 'is registered' and the CiviCRM Group Roles Synch - ie so those enrolled end up in the Smart Group and therefore get allocated the role to have access to the secret material - is missing some core steps you require?
Does each course have its own unique secret info?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Assigning drupal role after event registration.

This forum was archived on 2017-11-26.