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 (Moderator: Dave Greenberg) »
  • Auto Tag user when created through Drupal
Pages: [1]

Author Topic: Auto Tag user when created through Drupal  (Read 3746 times)

mjlucas

  • Guest
Auto Tag user when created through Drupal
March 07, 2008, 06:09:35 pm
Is there a way to have CiviCRM automatically assign a tag to a contact when they are created through a new Drupal signup?

For example: When a user signs up for an account in Drupal it will create/update a matching contact in CiviCRM.
  * When the contact doesn't exist in CiviCRM get Drupal to tag them with 'Drupal Created'
  * When the contact exists in CiviCRM and is updated don't tag them.

That way a smart group can be used to locate users who signup through the Website and their membership can be followed up by the Administrators (As apposed to offline signups)

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: Auto Tag user when created through Drupal
March 07, 2008, 06:15:47 pm

you can do this via the civicrm hook for contact creation/edit. The url will tell you that its a drupal registration form

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

mjlucas

  • Guest
Re: Auto Tag user when created through Drupal
March 07, 2008, 07:49:12 pm
I'm new to the code so don't know the best place to put things.

From what I can see the function civicrm_user() in civicrm.module gets call when registering. This further calls civicrm_register_data( $edit, $user, $category, false, true ) when data is posted to the register function.

This will call CRM_Core_BAO_UFMatch::synchronize( $user, true, 'Drupal', $ctype ); if a drupal user id is set which then calls synchronizeUFMatch() but we don't set the status flag so the value returned is the ufmatch and not the $newuser flag. (However it looks like the $newuser value is set to true even if a user is found with matchContactOnEmail?!)

I'd prefer not to modify any core CiviCRM code as these changes would need to be reapplied after the next update.

So if I modify civicrm_user() hook and add the tag to the register case then my code will add the tag for all users. I'm guessing the best place to put it is in the synchronizeUFMatch() function?

I'm sure there is a better way to do this and I'm just missing it!


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: Auto Tag user when created through Drupal
March 07, 2008, 11:43:20 pm

check:

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification

You can add the tag functionality to the post hook when a contact is created / editied and it is a drupal user registration url

You wont need to modify any core code for this :)

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

mjlucas

  • Guest
Re: Auto Tag user when created through Drupal
March 08, 2008, 09:49:49 pm
Ok, think I have a plugin that does what I want now. I'm seeing the following calls made to my module (function calls in order) when creating a user through drupal (there are CiviCRM profiles on the create account page)

_civicrm_validate
_civicrm_pre create Profile
    [email-Primary] => testemail
    [contact_type] => Individual
_civicrm_pre create Individual *
_civicrm_post edit Individual *
_civicrm_post create Profile
_civicrm_validate
_civicrm_pre edit Profile
_civicrm_pre edit Individual
_civicrm_post edit Individual
_civicrm_post edit Profile

It doesn't look like I ever get a post create event for an Individual (The operating type is returned as edit even though we started as a create [marked with a *] . Should I just hook it off the post create Profile? Or is that a bug with the hook calls?

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: Auto Tag user when created through Drupal
March 08, 2008, 10:10:24 pm

that is a bug and should return a post create hook. if you file an issue, we'll get it fixed for the release this week (the final release maybe?)

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

mjlucas

  • Guest
Re: Auto Tag user when created through Drupal
March 08, 2008, 11:08:54 pm
Done.

http://issues.civicrm.org/jira/browse/CRM-2815


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: Auto Tag user when created through Drupal
March 08, 2008, 11:23:34 pm

i assume u r running beta5. can you apply the following patch and try it out. let me know if this fixes the issue

http://biryani.osuosl.org:8181/rdiff/CiviCRM?csid=13599&u&N

thanx

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

mjlucas

  • Guest
Re: Auto Tag user when created through Drupal
March 08, 2008, 11:58:36 pm
Looks good. Was able to pull out the users details after a creation!

Cheers.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Auto Tag user when created through Drupal

This forum was archived on 2017-11-26.