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
9
votes
1answer
84 views

How do I modify the new 4.6 CiviMail form?

I am the author of a CiviCRM extension that needs to disable, depending on configuration, the URL tracking and open tracking checkboxes of the mailing form. In version 4.4 this was accomplished using ...
8
votes
5answers
352 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 ...
8
votes
5answers
381 views

How to change mailing form and set the default value for url_tracking to false?

Is it possible to alter the mailing form? I want to set the default value for url_tracking to false. Usually I would write a hook_civicrm_buildForm and set a custom default value but this hook is not ...
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" ...
6
votes
2answers
50 views

Can my extension know when other extensions become enabled or disabled?

My extension makes reports based on the Civisualize extension. I'd like to make dashlets out of the reports, but I only want it to be available when Civisualize is also enabled. It's easy to see if ...
6
votes
1answer
110 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 ...
5
votes
2answers
371 views

Using hooks — simple please

I am excited to be working with civicrm, but I am quite frustrated at this point and so I hope someone can help me. I can see how valuable hooks are, and it seems like they are actually very basic to ...
5
votes
2answers
87 views

I hacked core and know I shouldn't (How do I use hook_civicrm_batchItems?)

I need to adjust the CSV accounting batch export format for our accounting software. The CSV needs to be only four columns: Envelope number (a custom field which corresponds to our accounting ...
5
votes
2answers
201 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-...
5
votes
2answers
127 views

allow public access to entityRef field contact lookup

I need to add an entityRef lookup field to a public facing profile form so that users can search and select organization contacts. I patterned it after the current employer lookup in the contact ...
5
votes
1answer
122 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 ...
5
votes
1answer
142 views

What is the mechanism for tailoring an Angular form?

I want to modify the behaviour of an Angular form. The answer to question 4700 tells me 'how' to do it (add some JavaScript), but I'm interested in 'where' to do it. If it was a PHP form I could use ...
5
votes
3answers
261 views

Add custom field and populated with array/data from a non-civicrm table

newby here with a quick question about custom fields. Is it possible to set up a custom field that queries a non-civicrm table? Hoping to create an autocomplete dropdown menu that does a SELECT on a ...
5
votes
5answers
343 views

How do I hook into a contribution thank you page?

Big picture: I want to display some custom data on a thank you page for a specific contribution page. In my module I'm using hook_civicrm_preProcess. Like so: function ...
4
votes
3answers
187 views

How to create a hook in an extension?

I want to give others the chance to do something when certain events happen in my extension. So to be clear: I'm not wanting to use existing hooks in my extension, I'm wanting to create a new hook ...
4
votes
2answers
268 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, &$...
4
votes
2answers
284 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 ...
4
votes
3answers
543 views

How to set a default value for a custom field

EDIT: this is NOT working, at least in CiviCRM 5.24.2 EDIT: this is done automatically by CiviCRM from 5.18+ I have a custom fieldset on Contributions that uses an option list. The option list has a ...
4
votes
2answers
69 views

Is the postSave hook a supported hook?

This is different than the post hook, which is officially documented. The only real reference to the postSave hook I can find is CRM-7850, so I'm just wondering if it's supported or if it might ...
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 ...
4
votes
1answer
29 views

Is there a hook to impact custom data before it's saved?

I feel like I've hit this issue before and found a solution, but I'm drawing a blank right now. I need to be able to compare the value of a custom data field before it's saved in order to ...
4
votes
2answers
60 views

Can't change help_post text in Price Set using the civicrm_buildAmount hook

There are several fields I expect to be able to change in the buildAmount hook that just won't change for me. One example: function myext_civicrm_buildAmount($pageType, &$form, &$amount) { $...
3
votes
2answers
72 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) { ...
3
votes
1answer
200 views

Add Donations to Event Registration Form

I'm trying to give people an option to add donations to special projects when they register for a particular event. We could just point folks to the contributions pages, but it would be more effective/...
3
votes
1answer
135 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 ...
3
votes
2answers
51 views

How can I customize the default gear icon on a custom tab set?

Now that there are icons on all the tab sets (awesome, btw) - I'd like to change the standard gear icon that appears on any custom contact field sets that are set to display as a tab. I didn't see ...
3
votes
1answer
50 views

Is there a hook for on user sign in?

Is there a good hook for on CiviCRM sign in? [This is to display a message upon login in a cms-independent extension.] Thanks,
3
votes
1answer
82 views

How can I make every new Group a type Mailing List?

I have a request to enable making every new Group created (using search results -> Actions -> Add Contacts to Group) a group type Mailing List by default, thereby saving a user having to check the box ...
3
votes
2answers
76 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 ...
3
votes
1answer
240 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 ...
3
votes
1answer
124 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 ...
3
votes
1answer
168 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. ...
3
votes
1answer
17 views

membershipTypeValues hook not updating membership price

On my civicrm contribution page I have a field that I want to use to calculate the membership price. Currently Im trying to use the membershipTypeValues hook to edit the price after the contribution ...
3
votes
1answer
104 views

Extending CiviCRM Advanced search (queryObjects hook)

I am adding a Soundex featured to the advanced search. I am using the queryObjects hook to add this into the query. The documentation on this is spotty, only referencing CiviHR. I have downloaded that ...
3
votes
1answer
38 views

Documentation on the _civicrm_api3_* _spec functions

I have a working extension with a working API hook civicrm_api3_contact_getclif($params), but I can't find the documentation for the _spec function beyond the suggestion to have one I wrote this ...
3
votes
1answer
53 views

Suppress default CRM.alert in hook_postProcess

Trying to figure out an answer to this question, have tried to just disable a default CRM.alert using CRM_Core_Session::setStatus(null, false); in hook_postProcess (defined in a drupal module), but ...
3
votes
2answers
818 views

Refresh page after closing modal opened by .crm-popup outside of CiviCRM

We've a page (in Drupal) outside of CiviCRM for "editors" (mean, users with restricted permissions) to perform some civicrm tasks. From this page civicrm forms is being opened in modal frame via ....
3
votes
4answers
220 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
146 views

How to prepopulate custom fields

I would like to prepopulate a set of custom fields (on an activity) with data about the contact it pertains to. (The data I want to pull in is in a set of custom fields on the contact). My idea was ...
3
votes
1answer
153 views

Content for Custom Tab

I'm working on a hook to display a users PCPs on a custom contact tab. We use PCPs extensively and it would be great to see any pages the contact owns inside their contact card. (Rather than having to ...
3
votes
1answer
112 views

How do I modify a core CiviCRM file (to change a search order)?

Looks like one of core CiviCRM files (namely part of mySQL query at CRM/Contact/BAO/Query.php) has to be changed in order to achieve "Search results sort by Last Name". What would be the best (I mean, ...
3
votes
2answers
213 views

What hook(s) can modify variables passed into Smarty templates?

Recently I needed to modify Smarty variables being passed into a template from an extension. I tried a couple of likely hooks, but neither of them seemed to provide this functionality. The templates ...
3
votes
0answers
25 views

Building the equivalent of a webhook for certain CiviCRM events

I posted this in the Mattermost Town Square, but was encouraged to post the question here also: Good afternoon. I'm wondering if CiviCRM can produce a "changes stream" or fire off a webhook ...
3
votes
1answer
54 views

What is deleting my Tag?

I've run into this twice this month and scratching my head. Read this image upside down: We hit post create Address hook -> my regex extension creates a Tag - all good; happy dance; then something in ...
3
votes
1answer
71 views

Implementing tokens and tokenValues hooks for Event custom field

I'm trying to implement a hook for inserting Event custom fields into Scheduled reminders; however, I'm not a developer so I'm really not sure what the code needs to look like. The custom field is ...
2
votes
4answers
118 views

Can I disable Notify Activity Assignees for some Activities and/or user levels and leave it on for other Activities/user levels?

We're on Civi 4.6.21 and Drupal 7. Under Administer -> Customize Data and Screens -> Display Settings there is a setting - "Notify Activity Assignees - When enabled, contacts who are assigned ...
2
votes
3answers
361 views

Setting default date value via civicrm_buildForm hook no longer displays date

I have a custom module that invokes the civicrm_buildForm hook to set the default date for a given field to today's date. It is working - in part. When I examine the code I see that the default value ...
2
votes
2answers
879 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 ...
2
votes
1answer
62 views

Why am I getting a warning about hook_civicrm when Civi's cron runs?

On Drupal 7.73 with CiviCRM 5.29.1. Every time the CiviCRM cron runs, I get the following warnings in the Drupal watchdog log. Each is a separate entry. hook_civicrm_alter_drupal_entities should be ...
2
votes
3answers
210 views

post hook edit entity

We have a post hook that sends some data to an external api when a participant is created or edited. function kavo_civicrm_post($op, $objectName, $objectId, &$objectRef) { if (($op == 'create' |...