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 »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Separate Registration for Profiles
Pages: [1]

Author Topic: Separate Registration for Profiles  (Read 1944 times)

a110y

  • Guest
Separate Registration for Profiles
December 26, 2010, 07:48:15 am
Hello!
I am creating an application which requires users of two types:

  • Individual
  • Individual representing an organization

As CiviCRM has both these (contact) types, it seemed to be the apt solution.

However, the problem is that I would like to have two separate registration pages (one for individual and another for organization) which shows the corresponding profile on the registration page, and create the respective contacts. (i.e. When registering for an "individual" account an individual contact is created and when creating an organization account, an organization contact is created). I could not find any (simple) way of doing this and was hoping the experts could shed some light.

I hope I have made the situation clear. Thank you in advance.

P.S. In case my environment details aren't stated:

CMS: Drupal 6.20
CRM: CiviCRM 3.3.1

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Separate Registration for Profiles
December 26, 2010, 06:50:19 pm

You will need to use hooks and customized templates to accomplish this. We've done something quite similar in our "register a site project"

Check:

http://civicrm.org/civicrm/profile/create?reset=1&gid=15

The code is available here:

http://svn.civicrm.org/tools/branches/v3.3/drupal/modules/civicrm_regsite/

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

a110y

  • Guest
Re: Separate Registration for Profiles
December 27, 2010, 06:33:55 am
Hello Donald,
Thank you for the quick reply and useful resource. The project you pointed to is quite similar to what I am trying to accomplish however I seem to have failed to clarify. By "registration pages" I was referring to the default Drupal registration page. Thus, these profiles need to appear on the Drupal registration page. A sample case:

For an individual user:

1) Individual visits site
2) He/she clicks "register individual account" and gets redirect to user/register/individual
3) He/she is shown a form for filling details related to individual contact (First name, last name, etc.) along with username, password and email field
4) On submission an "individual" contact is saved

For a organization:

1) Individual (representing an organization) visits site
2) He/she clicks "register as representative" and gets redirected to user/register/organization
3) He/she is shown a form for filling details related to organization (organization name, email, headquarter address, etc.) along with username, password and email field
4) On submission a "Organization" contact is saved but a user is saved in drupal

Thus, when user A representing organization B posts a content, the organization name will be shown. However, if A has an individual account (at the same time) and posts content from his individual account, his real name will be shown.

I hope I've made it a little clearer.

Thank you for your time and the resources!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Separate Registration for Profiles
December 27, 2010, 07:06:44 am

I suspect you can do the same by implementing some hooks in drupal and civicrm. You'll need to be familiar with drupal and civicrm hooks (and php) to do the same

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Separate Registration for Profiles
December 27, 2010, 09:33:05 am
lobo is, as usual, correct. Using a custom Drupal module you could display only those profiles you want for each different register page, using those URLs you suggested as well. You should then be able to insure that the correct contacts (individual and organization) are then created.
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.

a110y

  • Guest
Re: Separate Registration for Profiles
December 28, 2010, 02:59:47 am
Hello herschel and Lobo,
After trying everything I could think of I have finally settled using default civicrm profiles with "Account Creation required" Restriction.

Quote from: hershel on December 27, 2010, 09:33:05 am
[...] Using a custom Drupal module you could display only those profiles you want for each different register page, using those URLs you suggested as well. You should then be able to insure that the correct contacts (individual and organization) are then created.

I did try this as well without luck (perhaps I was doing it wrong). I attempted to extract the profile forms using the profile api (api/v2/UFGroup.php) and civicrm_uf_profile_html_get function. But that resulted in a HTML markup (although I could use it with the form api) instead of a (native drupal) form structure (and as I understood that would completely ruin the validation, etc?). Perhaps my approach is incorrect?

Thank you for the answers. Until a better solution is found, I will settle with the "account creation required" constraint. :)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Separate Registration for Profiles
December 28, 2010, 03:10:31 am
> Perhaps my approach is incorrect?

Yes. The way I would suggest is to add all the fields to the default Drupal registration page and then use hook_form_alter to remove those fields not needed for any particular registration page. That is one idea how to approach this anyhow.
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.

a110y

  • Guest
Re: Separate Registration for Profiles
December 28, 2010, 03:21:56 am
I did try something similar however, profile with an "Organization" field cannot be appended to the Drupal registration page (If I understand you correctly, I don't know any other way of appending the profile to the registration page than "Used For: Drupal User Registration"). :(

And again, removing those fields with hook_form_alter still triggers the validation for some reason (and thus resulting in errors such as "Last Name is required").

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Separate Registration for Profiles
December 29, 2010, 09:31:07 am
I see what you mean. Offhand, I am not certain--could be you would have to manually create those fields in the Drupal registration page and then use the module code to read them and then update the newly-created contact record as necessary using the CiviCRM API.
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.

a110y

  • Guest
Re: Separate Registration for Profiles
December 29, 2010, 12:14:04 pm
Quote from: hershel on December 29, 2010, 09:31:07 am
I see what you mean. Offhand, I am not certain--could be you would have to manually create those fields in the Drupal registration page and then use the module code to read them and then update the newly-created contact record as necessary using the CiviCRM API.

That is exactly what I did. After hours of frustration, first the Organization field not being appended, then hook_civicrm_buildForm not adding custom elements to the profile; I decided to simply discard the seemingly "easy" ways and get into the code. Currently, I am modifying the registration form with hook_form_alter and then, as you said using the CiviCRM API to post-process the required fields. I believe this is the (only?) best (most flexible) solution (despite a little more work). It also makes deployment easier since everything is in code so no data migration (no unexpected errors on live site, no broken references, no headaches)! Hooray!

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Separate Registration for Profiles
December 29, 2010, 12:16:50 pm
No I meant use hook_alter_form to add similar fields to the user reg page (but as Drupal fields not linked to any CiviCRM fields) and then copy the data the user inputted into his contact record.
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.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Separate Registration for Profiles

This forum was archived on 2017-11-26.