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) »
  • How to call hook_civicrm_pre for profile in 2.0?
Pages: [1]

Author Topic: How to call hook_civicrm_pre for profile in 2.0?  (Read 1351 times)

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
How to call hook_civicrm_pre for profile in 2.0?
June 22, 2008, 01:22:15 pm
I posted my support question as a comment over in the wiki instead of here:

http://wiki.civicrm.org/confluence/display/CRMDOC/Changes+in+CiviCRM+2?focusedCommentId=7734310#comment-7734310

Feedback would be appreciated.

Cheers,
Joe
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

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: How to call hook_civicrm_pre for profile in 2.0?
June 22, 2008, 03:00:18 pm

can u post it here. the forums are a better place for discussion

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

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: How to call hook_civicrm_pre for profile in 2.0?
June 22, 2008, 06:26:45 pm
So what are the steps to running a hook_civicrm_pre function in a drupal module?

For example, if I want to inject some javascript into a profile used for Event registrations, it seems civicrm doesn't pick up that a mymodule_civicrm_pre() functions exists and needs to be called if it is merely residing in an enabled drupal module. Even if one includes civicrm.settings.php and CRM/Core/Config.php before defining the function, the function doesn't get invoked. Since it doesn't make sense to initialize civicrm on every drupal page load, what's some good sample code for invoking these hooks? I poked about in the repository for testing the v2 api but couldn't see sample calls.

Also, since profiles are anomalous, in that there does not seem to be an api file for them in contrast to objects like participants or contacts, I just want to check that the v 2.0 api for pre and post hooks still support them.
 
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

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: How to call hook_civicrm_pre for profile in 2.0?
June 22, 2008, 07:12:56 pm

hooks are only called when certain operations are done. typically they are called in CiviCRM when an object is inserted/updated in the db

Your example below (inject javascript used ina  profile) is probably best done by customizing the template (CRM/UF/Form/Block.tpl) and adding the js there conditionally (based on profile id)

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • How to call hook_civicrm_pre for profile in 2.0?

This forum was archived on 2017-11-26.