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
1
vote
0answers
11 views

'view' op in pre and post hooks: actually used anywhere?

Working on a PR to add pre and post hooks for the UFGroup entity, I looked for existing examples of entities that invoke these hooks with the 'view' $op (documented in the 'parameters' section for ...
0
votes
2answers
108 views

Use complete address and full county name in mailings

Working on a mailing that includes contacts full address details. And I'm encountering an issue for UK addresses where the county is abbreviated in the same way US states are. I've never seen such 3-...
2
votes
1answer
16 views

How to provide custom token for subscription related automated messages?

I'm trying to privide a token for mailing related automated messages. I followed the instructions about hook_civicrm_tokens and hook_civicrm_tokenValues but it does only work for "CiviMail" ...
0
votes
1answer
17 views

Adding a field to the Create Activity Form

I'd like to change the form that opens when adding an Activity to a Case (depending on activity type). Specifically, I'd like to add a field. I tried finding the fields I want to change in sites/all/...
1
vote
1answer
15 views

Hook postProcess doesn't work with message templates form

I'm trying to add a couple of fields to the message templates ("CRM_Admin_Form_MessageTemplates") in a custom extension. I use the "buildForm", "validateForm" and the &...
1
vote
1answer
23 views

Is there a hook that will be called before each database read?

I'm trying to get a little more familiar with writing extensions. I am still struggling with finding the correct / most specific hook function for my patches regularly. As a specific example, I am ...
2
votes
1answer
75 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 ...
1
vote
1answer
10 views

How can i check current user is administer in civicrm hook?

I am using the hook_civicrm_tabset for rename the tab name. Tab rename code is working properly. But i want to add condition if user is admin then rename the tab name. How can i check user is admin in ...
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 ...
2
votes
0answers
26 views

How to use a GROUP_BY / HAVING in extended Advanced Contact Search query?

Based on this solution, I'm trying to add a custom pan in advanced search in order to filter by Line Item Total Sum. The context I successfully manage to filter by Line Item Total with these fields: ...
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 ...
0
votes
0answers
53 views

Creating membership with civicrm_api3, inherited membership

I'm trying to create inherited memberships in the civicrm_post hook. I feel like there is something wrong with the api itself. The API doesn't even recognize my only membership id in the database. ...
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 ...
1
vote
1answer
12 views

Control duplicate entries in Hook Post

I'm in need of inserting a control query into a hook post to retrieve if there is duplicate data. I am using a php query but the only reaction I have is that it continues to compute forever, is it ...
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 ...
1
vote
1answer
23 views

Using hook_civicrm_tabset; why doesn't my tab focus when linked to via url?

I've added a tab adjacent to the event "Info and Settings" configuration tab, using hook_civicrm_tabset(), but when I link to the URL for that tab, the "Info and Settings" tab is displayed. This ...
0
votes
1answer
22 views

How to call my post_provision_install hook after CiviCRM installed?

I want to automate the removal of households from CiviCRM, right after it has been installed via Aegir on Drupal 7. I implemented my post_provision_install hook, but it runs before the same hook of ...
1
vote
1answer
25 views

how can I create an hook when external id change

I would to ask you , on how can create an event (programatically) when I change the external ID in contact form, how can I t make some kind of process like validation in another module or service I ...
1
vote
0answers
18 views

Errors not showing against custom fields using hook validateForm()

Using this code if ($fields["custom_111_79"] == 0) $errors["custom_111_79"] = "Please enter number of physio sessions"; The evaluation is done correctly, but the error message does not appear ...
1
vote
1answer
15 views

Get Contact id from Relationship to use in a Hook [duplicate]

I want to display Contact B ID of a relationship for the current contact. I am building a hook and this is my code so far. if ( $formName == 'CRM_Contactlayout_Form_Inline_ProfileBlock') { if ...
1
vote
0answers
29 views

Stripe Webhooks on a multisite?

I've just updated a multi-site with the latest Stripe extension and I get the message to update the webhooks. Did this on another site earlier I was able to just follow the links and it updated as it ...
1
vote
1answer
36 views

Ways for an extension to determine how (by which form/screen/API) a Contribution was created?

I'm creating an extension. It should: intervene when a Contribution is created, and make some changes to the data only intervene if the Contribution was created via a public-facing Contribution Page, ...
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 ...
0
votes
1answer
30 views

How to set a permission using drupal ACL?

I am developing an extension. I want to provide permissions using drupal. I am using following hook for creating a permission hook_civicrm_permission(&$permissions); But, how to do that (means ...
1
vote
1answer
52 views

Validation radio custom fields on civicrm_validateForm hook does not work

I have a custom field on contact in radio type format, not required field. I'd like to set up custom error on this field by using hook_civicrm_validateForm when the field is null. // hook in ...
0
votes
0answers
35 views

How to alter a query in hook_civicrm_pageRun based on a custom filter provided?

I want to alter the query run in the hook_pageRun(&$page) under Manage Events Page to alter the (event list) results shown here. I can alter the rows from hook_civicrm_pageRun , but I want to ...
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 ...
1
vote
1answer
20 views

Hook pre/post in pledge changed status

On 5.6.0 After create a pledge. If is created a new contribution that change the status of the pledge from "Pending" to "Completed" is not incoming in any hook_civicrm_post or hook_civicrm_pre with ...
0
votes
1answer
33 views

I am trying to insert custom tab into Activity tab but it is not working

I am creating new extension. I am adding a new custom field into Activity tab but it's not working //Creating a custom group for survey function custom_group_create_survey(){ $survey_custom_group = ...
1
vote
2answers
27 views

Is there any information that tells the last action of membership record (edit or renewal)?

I'm going to write a hook to distinguish a saved membership record, how do I know the last action of saved membership record is edit or renewal?
0
votes
1answer
149 views

Adding a column to search results

i try to add a custom column to the search results of "find contact". I use the hook "searchColumns", i can easily add a column with: $headers['summary'] = array('name' => 'Summary'); , but when ...
0
votes
1answer
27 views

How to fetch Profile gid from hook_civicrm_post included in a Contribution Page?

I am using profile object inside function hook_civicrm_post($op, $objectName, $objectId, &$objectRef){ } How can I fetch the Profile gid from the above variables? or is there any way to ...
1
vote
1answer
61 views

Add new smarty template to an existing page

I want to add a new template part to the activity edit & view page, I have been trying number of hooks to do it but could not figure out which one best to use. I am trying to do something similar ...
2
votes
1answer
24 views

Which table is used for hook_civicrm_triggerInfo?

I have a rebuild trigger action that is failing. It is trying to create a trigger on civicrm_contributiion_recur. Clearly it has 2 i's and shouldn't. There is or was a trigger on the table without ...
1
vote
2answers
29 views

How to automatically remove a contact from specific group, if end date is added to specific relationship

If end date is added to relationship,the contact should be automatically removed from the specific group. How this can be accomplished?Any suggestions?
1
vote
2answers
66 views

Contact Summary Hook Implementation

I am trying to add contact created date in contact summary. I am sure that https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_summary/ helps the requirement. But I'm not getting how to ...
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 ...
1
vote
2answers
85 views

How are CiviCRM form names defined (civicrm_validateForm)?

I am attempting to perform form validation on various CiviCRM forms (profile forms and forms within contribution pages) by hooking into hook_civicrm_validateForm. In my php code, I would like to ...
0
votes
1answer
22 views

Hook to stop a contact's email from being deleted

We have a new requirement to stop an admin from deleting a contact's email if that email is found in one of our other systems. I am trying to do this through a validateForm hook. I can figure out ...
0
votes
1answer
66 views

How do you set the displayed text of a custom field (“view-only”)?

I am using Drupal and I have an extensions that I am running this code on. I've seen several threads attempting to help with this. I haven't found any that really make it clear. From what I ...
0
votes
1answer
53 views

Wordpress hooks – some don't work

I noticed that some hooks are not firing… I have the following three hooks <?php add_filter('civicrm_permission', 'civicrm_permission', 10, 1); function civicrm_permission(&$permissions) { ...
0
votes
1answer
27 views

Customise Contacts Relationships Tab

I want to customise the contacts relationships tab screen to show if the listed contacts (Individuals) belong to a specific group or not. I'm not sure where to start and would appreciate any pointers. ...
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,
1
vote
0answers
110 views

Which civicrm hook for Event Registration form field content change in Drupal module?

Preamble: Event Registration Settings form ( civicrm/event/manage/settings?reset=1&action=update&id=EVENT-ID ) has separated text areas for Event Summary/Description ( "Info and Settings" ...
2
votes
0answers
36 views

Change displayed value for customfield

I have a custom field of an individual that stores the ID of a group (as int). I would like to change the display of the field to show the actual name of the group instead of the ID (same as contact ...
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' |...
0
votes
1answer
50 views

How to echo “Hello World” in civicrm?

I need to echo "hello world" in civicrm how to do this in any page in civicrm? i'm trying to do this using hooks_civicrm_post but there is no result.
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 ...
1
vote
0answers
118 views

Setting Default Value BuildForm Hook does not work

I tried to implement the following hook (in my extension "cividoncamillo"), to set a default Contribution Type, but it does not work... Any Ideas why not? //does not work function ...
2
votes
3answers
139 views

How to customise the activities tab listing

I used to hack the Activities BAO to change the search results to make the subject line something more useful; i.e. extract other data from particular activity types and auto-create a summary in place ...