Questions tagged [hooks]

Hooks are a powerful way to extend CiviCRM's functionality, incorporate additional business logic, and even integrate CiviCRM with external systems. The way they work is, that at key points in processing CiviCRM checks if custom code is "hooked in", and runs any valid code it finds.

Filter by
Sorted by
Tagged with
2
votes
1answer
50 views

Should civicrm_post hook receive populated Relationship object following relationship enable/disable in UI?

I'm porting some code using Civi hooks from Civi 4.4 to 4.6 . The code needs to know when a relationship becomes active or inactive, regardless of how that happens, including via the enable/disable ...
5
votes
2answers
195 views

How can I assign tag when certain profiles are submitted

Anyone who signs up online for a membership on our site must create a Drupal user account at the same time (advanced setting on profile used for membership sign up). This gives them access to member-...
1
vote
1answer
44 views

Custom Hook causes for a PCP problems on event registration page

I have a custom function written to show the name of the contribution page that a PCP is a part of. After some help from the community, I got it working, hooray! Trying to write a hook to add ...
3
votes
2answers
73 views

How can I hide specific tabs in member view regardless of viewer permissions?

We have two different user permission groups: Finance team who can see the Contributions tab, and Personnel, who can't. We wanted to hide some custom field tabs for both groups, and mimicked the ...
2
votes
1answer
49 views

Is there a hook for when a CiviMail is created/scheduled/sent/completed?

I want to call a function whenever a CiviMail is sent from our system, to send a log message to a third party system (Slack in this case). I've had a look at the CiviCRM documentation, and while I ...
3
votes
1answer
230 views

Can tokenValue hooks be used in scheduled reminder emails?

I have the same problem as at http://forum.civicrm.org/index.php/topic,32608 I have created a tokenValues hook to fetch the value of a field from a multi-record custom field set. I have the token ...
1
vote
1answer
54 views

How do I call an SMF function from CiviCRM?

I want to write a postProcess hook to post submitted form info to a Simple Machines Forum. How do I call SMF functions from Civi?
6
votes
1answer
109 views

Membership proration

I'm attempting to setup proration on fixed memberships via the civicrm_membershipTypeValues hook. I'm assuming that once the minimum_fee value is modified, this new amount should display on the ...
3
votes
1answer
132 views

Where to put api wrapper class in an extension

I just wrote an extension with short-name "genderselfidentify" (it's cool, you should check it out), which implements hook_civicrm_apiWrappers. This hook requires you to declare a class for your api ...
4
votes
2answers
67 views

How to limit number of contacts in a group?

I have a max no of users limit for a group, so whenever someone adds a groupContact using the civicrm dashboard, I would like to present them with an error which prevents adding a new group and ...
3
votes
2answers
71 views

Trying to write a hook to add contribution page name to Main.tpl I'm super close

So I've almost got a hook working to add the name of the contribution page to the main.tpl part of a PCP. This is what I have so far: function wordpress_civicrm_buildForm($formName, &$form) { ...
1
vote
1answer
24 views

Can't get hook_civicrm_contact_get_displayname to work

I want to append a custom field to the display name. To try it, I used the example. function ccas_hooks_civicrm_contact_get_displayname(&$displayname, $contactId, $objContact) { $displayname = $...
8
votes
5answers
346 views

How to display a Drupal view in a CiviCRM tab

I'm trying to display a drupal view in a CiviCRM contact tab. I've tested out my tab function with the code snippet on hook_civicrm_tabs and it will show the contribution tab correctly, and I've ...
1
vote
1answer
51 views

Can hook_civicrm_links create links beside rows of a contact's Events tab?

I've looked at CRM/Event/Selector/Search.php to see it creating the View/Edit/Delete links, but am just unsure how to make this work. Can someone advise what the appropriate $objectName and $op should ...
4
votes
2answers
273 views

Hook to change the Success message after CiviCRM submits a form?

I'm writing an extension implementing hook_civicrm_post to move contributions from individual to household if the individual is part of a household. However, I'd like the form to either redirect to ...
3
votes
1answer
122 views

Custom code that sets custom field value stopped working in 4.6

I have some code in a custom module (in the civicrm_pre hook) that sets a custom field value, using the function CRM_Core_BAO_CustomValueTable::setValues Here's a print_r of the parameters it is ...
1
vote
1answer
67 views

How do I add Javascript to pages using Core functions?

I'm calling this from a hook but it's not working. Am I doing something wrong? CRM_Core_Resources::singleton()->addScript("alert('hello');"); I confirmed that it's running by adding debug code to ...
6
votes
2answers
153 views

How do I use the API to access protected custom data in a hook?

I have custom data for events that is not visible to anonymous users (it's for internal use only). I want to access that data from my implementation of hook_civicrm_post(). When I call the API "get" ...
1
vote
2answers
282 views

How do I add new tab to the Contact Summary Page?

I create a new plugin and I try to use hook for adding extra tab in the contents, my question is how to get $contactID? add_action('civicrm_tabs', ' civitest_civicrm_tabs'); function ...
3
votes
4answers
211 views

Can I find the target contact ID in hook_civicrm_buildForm?

Summary Is it possible to extract the target contact ID of a form during hook_civicrm_buildForm? Details We are trying to manipulate a wide range of fields across the site, ones that might be ...
3
votes
1answer
164 views

Can I update/requery a custom field that got changed via another field on the same page?

I created some database triggers that update a read only custom field that is displayed on the main contacts page. You change the value in another field and the db triggers update the custom field. ...
2
votes
2answers
857 views

How to insert Javascript into an inline form edit via an extension?

Normally, if I want to inject a Javascript snippet into a form, I use a hook like in an extension like this: function alternateduplicatecheck_civicrm_buildForm($formName, &$form) { if($formName ...
4
votes
2answers
260 views

Is there a CiviCRM hook or other method which can be used to push data updates to other systems?

We are attempting to keep two systems in live sync with each other, one is CiviCRM. There are hooks in civicrm for: Pre database saving of data hook_civicrm_pre($op, $objectName, $objectId, &$...
5
votes
1answer
120 views

How do we preprocess CSV columns when using CiviCRM builtin import functionality?

We use CiviCRM's import data functionality (and api-csv-import-gui) to import partner's contributions from CSV files. This is working great because the CSV columns can be mapped to CiviCRM fields via ...

1 2
3