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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Hook into profile submission? Need to log in activity history.
Pages: [1]

Author Topic: Hook into profile submission? Need to log in activity history.  (Read 2384 times)

danh

  • Guest
Hook into profile submission? Need to log in activity history.
January 12, 2008, 02:32:34 pm
Hi,

I think I need to understand how I can trigger the creation of a timestamp of some sort for a contact upon their submission of a profile form.  I'm hoping there is a hook of some sort that I can use.

The bigger context is that I'm trying to set up a petition.  All I want, is to let people sign it, and have them stored in our CiviCRM DB in a way that they can be redisplayed in the order they signed (this is why I need a timestamp).

My approach is simply to set up a profile in civicrm with the extra fields needed for the signatures, and then have the submission form for this profile in a drupal page.  When that profile is successfully submitted, what I would love to happen, is that a custom bit of code would run-- a hook, or something registered as a listener? -- that would call crm_create_activity_history() on the contact just created/modified, adding the time that this person signed the petition.  Or, just to fill in a custom data field (part of the petition profile) with the current time and date. 

I'm getting pretty good with Drupal code, but am new to the innards of CiviCRM.  Can anyone here help me out?

Many thanks!

Dan

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: Hook into profile submission? Need to log in activity history.
January 12, 2008, 05:59:55 pm

There are a couple of drupal petition modules which integrate with CiviCRM that you should first investigate (IMO).

http://drupal.org/project/signit
http://drupal.org/project/petition

They do have example of using civi hooks to accomplish the below

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

danh

  • Guest
Re: Hook into profile submission? Need to log in activity history.
January 14, 2008, 08:52:58 am
Thank you, lobo. 

I have already looked into these.  Petition appears to have been abandonned, not having even been ported to 5.x yet.  SignIt says it is actually a fork of Petition, and is still being actively developed.

I had already tried installing SignIt both on the site I am talking about, and on an out-of-box clean install of Drupal 5.5, but I can't see how to get it running.  I've got all its permissions turned on, but still the admin pages listed in hook_menu() aren't showing up, and I can see how to make it do what it is supposed to do.  Just got frustrated with that, and thought that a simple profile submission might be simpler.

Any easy advice on what to do with that?  If not, maybe I'll just try a little harder to get SignIt working, maybe post an issue about it, or look in its innards to see how it does timestamping in CiviCRM.

Thanks again,
Dan

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Hook into profile submission? Need to log in activity history.
January 14, 2008, 02:18:59 pm
Dan - If you can't make progress with Signit, you should be able to use our post hook plus an API call to do what you want. Have you looked at the CiviCRM hook doc / example here?

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

If you wind up coding something - I'd recommend coding it against 2.0 since the schema for Activities has changed substantially. The Activity History object has been merged into Activity.
Protect your investment in CiviCRM by  becoming a Member!

danh

  • Guest
Re: Hook into profile submission? Need to log in activity history.
January 14, 2008, 02:27:50 pm
Thanks a lot!  Will be working on this again in a few days, and will post to let you know how it went.

Dan

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Hook into profile submission? Need to log in activity history.

This forum was archived on 2017-11-26.