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
6 answers
453 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 ...
Philipp Michael's user avatar
5 votes
2 answers
257 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-...
JoAnne's user avatar
  • 3,450
3 votes
1 answer
123 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, ...
yurg's user avatar
  • 2,005
3 votes
1 answer
295 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 ...
Norris's user avatar
  • 870
3 votes
1 answer
227 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. ...
Paul-Tahoe's user avatar
  • 2,933
3 votes
2 answers
1k 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 ....
yurg's user avatar
  • 2,005
9 votes
1 answer
87 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 ...
konadave's user avatar
  • 192
8 votes
5 answers
408 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 ...
Emily F's user avatar
  • 81
5 votes
1 answer
160 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 ...
Ken West's user avatar
  • 1,047
4 votes
2 answers
345 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 ...
Jeff Mikels's user avatar
4 votes
3 answers
300 views

Controlling Available Search Kit Actions at a Granular Level

Some permissions allow actions that may not be desirable to have as a search action that can be done en masse. e.g. I may want contacts to merge records but not delete records en masse on a search ...
Andy Burns's user avatar
  • 3,571
4 votes
3 answers
795 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 ...
artfulrobot's user avatar
  • 3,920
4 votes
1 answer
120 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 ...
David Hayes's user avatar
3 votes
2 answers
107 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 ...
Norris's user avatar
  • 870
3 votes
1 answer
174 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 ...
Coleman's user avatar
  • 18.3k
3 votes
2 answers
86 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) { ...
RayWright's user avatar
  • 2,488
2 votes
1 answer
55 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 ...
davejenx's user avatar
  • 2,365
1 vote
1 answer
38 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 ...
emma's user avatar
  • 463
1 vote
1 answer
80 views

Invoking hook_custom_tokens and hook_custom_tokenValues in Joomla

I have tried, in vain, to invoke hook_civicrm_tokens and hook_civicrm_tokenValues in a Joomla instance in order to add custom tokens (to be specific: relationship information). I created a Joomla ...
Stephen Palmstrom's user avatar
1 vote
1 answer
79 views

Enforce uniqueness of custom field

I created a custom field on groups, which contains a string. When this string is not empty, I want it to be unique. What is the preferred way to do this? Should I implement a hook?
johanv's user avatar
  • 402
1 vote
1 answer
60 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 ...
Nicholai's user avatar
  • 2,838
1 vote
1 answer
202 views

Update custom field from other custom data

I'm trying to use a php hook to automatically create a relationship between two contacts. Let me set the stage for you. Meeting Extender: a custom data set that extends the meeting activity(activity ...
Vito Mantese's user avatar
0 votes
0 answers
56 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 ...
harshal's user avatar
  • 841
0 votes
1 answer
45 views

get source table values in civicrm_triggerInfo

I have created below hook for trigger some values in my table. Here how to get source table values that are being updated or inserted function history_civicrm_triggerInfo(&$info, $tableName) { ...
ManiMuthuPandi's user avatar