title: Filing activities on closed cases

text:
# Question
Title: Filing activities on closed cases
In Civi 4.6, when you filed/moved and activity to a case, you could choose a closed case from the list. In fact, there was a conditional to show closed cases with a strikethrough. In 4.7, when everything was moving to EntityRef that little piece was removed and all references to "file on case" assumes the case is open.

While I've been able to track down some lines I could comment out (in the parameters of the addEntityRef) to allow closed cases to populate the list again - that means a custom PHP file. I guess I was wondering if it is predominant that people only file on open cases? The behavior feels strange that you wouldn't want to be able to include (or have an option to on the form itself) closed cases.

Does anyone else file on closed cases and have a different workaround?

# Answer
UPDATE: Can do this with an extension using hook\_civicrm\_alterEntityRefParams. It also magically adds a Case Status filter in the "refine search" dropdown that appears when you start typing a name. See https://lab.civicrm.org/dev/core/-/issues/2209#note\_51075 and https://github.com/AsylumSeekersCentre/civicrm-moveActivityToAnyCase

---

While I'd vote to bring the ability to file on a closed case back, or maybe make it a configuration option to allow or not, one workaround is to use the email processor and put the case id in square brackets in the subject (https://issues.civicrm.org/jira/browse/CRM-21446). It will happily file it on a closed case. Information about setting up the email processor is here https://docs.civicrm.org/sysadmin/en/latest/setup/civimail/inbound/#autofiling-email-activities-via-emailprocessor

And if you edit an activity and add the case id in square brackets to the subject and then save, it will file on case, e.g. "this is the subject \[case #1234\]"

According to the issue you linked, https://issues.civicrm.org/jira/browse/CRM-17645 you should be able to use a hook\_civicrm\_entityGet in an extension to alter the query, but I'm not sure from those notes that it actually got implemented.
> 2 votes

---
Tags: civicase, activities
---


title: Override CiviCRM settings

text:
# Question
Title: Override CiviCRM settings
I want to override my CiviCRM settings. I am new with CiviCRM and I don't know where to put the line referenced in the attached image. Thanks in advance.

# Answer
I believe you need to update the directory "/var/www/testing/sites/default/files/civicrm/upload" to reflect your installation directory:

```
/var/www/yoursitefoldernamehere/sites/default/files/civicrm/upload

```

There may be another subfolder in your setup, like htdocs before the 'sites' folder as well.
> 1 votes

# Answer
You need to add this in civicrm.settings.php. Once you have added overided the settings clear CiviCRM cache so that the settings are updated correctly.

HTH

Pradeep
> 2 votes

# Answer
I think this could be an issue with your server settings w.r.t. the permissions on that file. basically it is saying 'you don't have permission to edit/save this file' so you either needs to fix them or use sudo
> 1 votes

---
Tags: settings
---


# Question
Title: How do I run CiviCRM PHPUnit tests from within Netbeans?
I want to run PHPUnit tests from within my IDE - and I know Karin G. has created excellent directions for PHPStorm, but I use Netbeans 8.2. What can I do?

# Answer
\[This all assumes you have `civicrm-buildkit` already working and that you can run CiviCRM phpunit tests successfully from the command line.\]

## 1. Tell Netbeans which phpunit executable you're using.

* Go to **Tools » Options**, then **PHP** tab, **PHPUnit subtab**.
* Set the path of your PHPUnit script. See screenshot:

## 2. Create a shell script with your environment variable.

Copy this script into a file anywhere on your filesystem:

```
#!/bin/sh
env CIVICRM_UF=UnitTests /path/to/your/phpunit5 $@

```

## 3. Tell Netbeans where to find your tests.

* Go to **File menu » Project Properties**, **Testing** tab.
* Click **Add Folder** and select the `<civiroot>/tests/phpunit` folder. See screenshot:

## 4. Tell Netbeans the CiviCRM-specific info it needs.

* Go to **File menu » Project Properties**, **PHPUnit** tab.
* Check the **Use XML Configuration** box.
* Set the XML Configuration path to `<civiroot>/phpunit.xml.dist`.
* Check the **Use Custom PHPUnit Script** box.
* Set the **PHPUnit Script** to the path of the file from step 2.

## 5. You're ready to go!

From any PHP file in the main codebase, press `Ctrl-F6` (or **Run menu » Test File**) to start your tests. You can also re-run only failed tests.

## Troubleshooting

If PHPUnit isn't working, bring up the "Output" window (**Window menu » Output**). This will show you the exact command Netbeans tried to run. You can run it on your command line to compare results and tweak it.
> 4 votes

---
Tags: developer, unit-testing, phpunit
---


# Question
Title: Case Manager is not shown for closed cases
I'm testing an upgrade from 4.6.38 to 5.5.3 and have noticed a new case related behavior that feels a little strange to me. When you close a case and subsequently the case roles expire and are disabled they no longer show on the manage case screen (in the roles section).

This issue prompted a PR that I think is the cause. If a civicase is reopened why isn't the Case Coordinator (and other roles) reinstated?

I've not been in 4.7, so the verbiage 'reinstate' roles is confusing to me. In 4.6.38, when a case was closed while the relationship may have been inactive but the case manager still showed on the case. As Demerit pointed out as a comment on that issue "I'm pretty sure they used to stick around - maybe something changed recently. Otherwise, you wouldn't be able to see what they were on closed cases."

I've verified on the demo site that if you close a case, case roles do, in fact, 'disappear' on the manage case screen. This is strange to me, why wouldn't you want to be able to reference who a case manager was on a closed case?

https://lab.civicrm.org/dev/core/commit/0fd841b07dfbb958a1c4ae8349131b3325b15dc4

In the PR, line 849 has, $activeOnly = TRUE. If I set that to FALSE, I can see case managers on closed cases. But I'm afraid that will have an effect beyond the manage case screen. Can this variable be set for just the manage case screen to "FALSE" so that you can still see Case Managers on closed cases?

# Answer
> 3 votes
There is now a fix submitted on GitHub to handle this issue - https://github.com/civicrm/civicrm-core/pull/13144.

This should be a part of the next release, possibly 5.8.9.

---
Tags: civicase, roles
---


# Question
Title: What does the error mean when enable honoree in contribute I get an error CiviCRM 4.6.8
CiviCRM 4.6.8: When I enable honoree in contribute (even with the default setting: Honor type: "In honor of", "in memory of " and Honoree profile: "Honoree Individual " ) I get a warning: "warning the selected profile is using a custom field which is not assigned to the 'Contribution' being configured"

What does that mean?

Oddly I can use the test-drive link but not the live link. I can disable the honoree section and it works too.

What do I do wrong?

I tried it on the demo site http://d45.demo.civicrm.org but it seem to work there. (different version)

# Answer
This is quite complicated, but as @pkeogan explains above, it all comes down to your profile using a custom field. To see custom fields that are restricted to specific contribution types, go to Administer \> Customize Data and Screens \> Custom Data. Then you can see the allowed types for each fieldset in the Type column. You need to locate the one that your Honouree profile uses, but which does NOT include your contribution type in the Type column. (If you're unsure, go to Administer \> Customize Data and Screens \> Profiles, and see for the fields in your profile.) Then, on the page at Administer \> Customize Data and Screens \> Custom Data, click ”more” on the relevant row, and then ”Settings”. There, see for the label ”Used For” to choose the types you need.

To understand this better, read the pages Creating Custom Fields and Profiles in the CiviCRM documentation.
> 3 votes

# Answer
If the error still displays, then you most likely have an issue with a custom field in your profile. I think you have a profile containing a custom field that has a restriction on the type of contribution type and that the contribution page uses a different contribution type.
> 2 votes

---
Tags: civicontribute, custom-fields, 4.6.8, honoree
---


# Question
Title: Anyone else having trouble with API Explorer v4
Compare the two screenshots below. API Explorer v3 is acting as expected, but v4 is misfiring. Couldn't find anything related here nor in the issues list. Can't help but think I'm missing something basic! Config is Civi 5.7.0, API v4.1.0, Drupal 7.61, PHP 7.1.22, Chrome 70.0.3538.77.

# Answer
> 4 votes
Im replicating your API4. I'm testing this on the same set up. Works fine here. Only diff is Im using the Shoreditch theme.

Perhaps you need to do a reinstall or clear caches?

---
Tags: api
---


title: QuickSearch not working

text:
# Question
Title: QuickSearch not working
I'm dealing with a system where the Quick Search box is not working. Using the browser dev tools shows ajax requests being sent but receiving a '406 Not acceptable' error.

According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406 this relates to content negotiation.

The AJAX URL is:

```
https://example.com/administrator/?option=com_civicrm&task=civicrm/ajax/rest&entity=contact&action=getquick&json={"name":"a","field_name":"","table_name":"cc"}

```

and the content negotiation headers in the request are:

```
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en;q=0.5

```

This matches what I see on another system that is working normally.

This is CiviCRM 5.5.2 on Joomla 3.8.13

Any ideas?

# Answer
Does the webserver support compression? Might be a disabled module (e.g. mod\_gzip in apache). The Accept-Encoding suggests only compressed data is accepted.
> 0 votes

---
Tags: joomla, quicksearch
---


title: How do I restore deleted contacts

text:
# Question
Title: How do I restore deleted contacts
I've accidentally deleted a number of contacts. How do I restore them so that they are still members of my organisation?

# Answer
> 2 votes
Short version, assuming you mean they are just in Trash, is

* go to Adv Search,
* tick the box for 'search in trash'
* select the ones to restore
* then under Actions choose 'restore from trash'

# Answer
> 0 votes
There are some instructions at https://docs.civicrm.org/user/en/latest/the-user-interface/undelete/

---
Tags: contacts
---


# Question
Title: Getting Apache 500 error when using CiviProxy
Because I haven't seen this topic here, I assume I'm handling a rather basic configuration error, but I've been stuck for three days now:

I've downloaded the latest CiviProxy release (0.6.dev1) following the instructions on https://docs.civicrm.org/civiproxy/en/latest/installation/#installing-the-proxy-scripts-your-your-civiproxy-server and adapted the values for

```
$proxy_base     = 'https://civiproxy.mydomain.org';
$target_civicrm = 'https://www.mycivicrm.de/civicrm';

```

Basically, my setup seems to work. If I access https://civiproxy.mydomain.org/index.php I can see the CiviProxy page. I also adapted

```
// API and SITE keys
$api_key_map = array('civiproxykey1' => 'civicrmkey1');
$sys_key_map = array('civiproxykey2' => 'civicrmkey2');

```

and kept the already existing rule

```
$rest_allowed_actions = array(
  'all' => array(
    'Contact' => array(
      'getsingle' => array(
        'email' => 'string',
      ),
    ),
  ),
);

```

The target system is running CiviCRM 5.6.0.

If I run https://civiproxy.mydomain.org/rest.php?entity=Contact&action=getsingle&key=erikhtestkey&version=3&json=1&api\_key=testerikhapikey&email=pipotest@example.org (with adapted key values of course), I get an Apache 500 error. Accessing CiviCRM directly (with adapted keys) returns some data, so it looks to me like every component is doing fine but the connection is not working. My basic key usage seems to be OK. At least I get an "invalid key" error if I intentionally use a wrong key.

In order to see whether CiviProxy is trying to contact CiviCRM in the first place, I ran tcpdump on the CiviProxy server and saw no data going out to CiviCRM. `curl https://www.mycivicrm.de/civicrm` is doing well, so my current assumption is that for some mistake I made in the CiviProxy setup, it is not even trying to connect to CiviCRM. I also tried installing CiviProxy on the CiviCRM server, but didn't succeed either.

The de.systopia.civiproxy is installed on the CiviCRM server. I can provide the configuration on that system as well, if needed.

Kind regards,

Anna

# Answer
The key to this would be the actual error message. HTTP Error 500 usually means that PHP encountered a fatal error, which should end up in the webserver's error log. Could you have a look? It could be in /var/log/apache2/error.log, but it depends on your configuration.

Also two remarks (you probably already know this):

* The de.systopia.civiproxy extension is only required if you want to send out mailings; it changes the contained URLs to the proxy
* Installing the proxy scripts on the same environment is not what we had in mind, the ideal place would be a separate environment in the DMZ.

Cheers Björn
> 0 votes

---
Tags: error, configuration, 500
---


# Question
Title: How to create a new contact type other than "Individual", "Household", or "Organization"?
Sorry if this is not the best place to ask or if I sound vague, I am very new to CiviCRM and would be grateful for any advice I can get.

I am using CiviCRM for a local nonprofit animal shelter. Currently I have the pets stored as an "Individual" subtype, and added a custom field group for Pet Details that I basically would want to replace the "Contact Details" section, since none of that information is relevant to a pet. I'm starting to think that a better course of action would be to somehow create an entire new contact type just for pets.

My options are to either try to hide the "Contact Details" section of the pet subtype, or create a whole new Contact Type just for pets. I'm not sure how to go about doing this or if there is even a way to do this without editing the core code of Civi.

Thanks in advance, any advice is greatly appreciated.

# Answer
> 2 votes
it may be also worth familiarising yourself with what https://github.com/civicrm/org.civicrm.contactlayout can do in terms of changing the configuration of the Summary Screen. It allows you option of creating multiple layouts but i don't recall if they can be contact sub-type specific but am pretty sure it does

ah yes

> Managing Multiple Layouts The "Show" option can specify a contact type, e.g. if a layout is specifically designed for Organization contacts rather than Individuals.

# Answer
> 2 votes
You can't create a new Contact type at the level of Individual/Household/Organisation (although most things are possible with enough code!).

However, you can create subtypes of those, so you could create subtypes of Individual as Pet and Human. For the Pet subtype you can create custom fields relevant to them and with the Contact Layout extension that Pete mentioned you can customise what gets displayed.

The Human subtype is optional - if you use it, you want to ensure all people have that subtype which is a complication, but on the other hand when you search it is easier to specify subtype=human than trying to exclude those with subtype=pet.

---
Tags: contacts, contact-types, sub-types
---


# Question
Title: Is there a direct way to clean the Civi Cache?
Cleaning the civi cache updates the Smart Groups immediately (instead of waiting 5 minutes).

Is there a way to clean the civi cache directly (instead of Menu\>Administer\>SystemSettings\>Cleanupcache&updatepaths\>Cleanup Caches)

(I am not a programmer, but I may be able to include it in a small php program, if I am told how to do it).

# Answer
> 2 votes
You will find different ways of clearing cache (as Jon mentions) documented **HERE**, but I agree with Tony that perhaps the UI would be easier - maybe it's just a question of adding a top menu item on the **navigation menu** or a button that will trigger /civicrm/clearcache?

Hope this helps! Tamar

# Answer
> 2 votes
Expanding on Tamar's suggestion:

Go to `Administer > Customize Data and Screens > Navigation Menu`
Click `Add Menu Item`
Title: Clear Cache
Url: `/civicrm/clearcache`
Parent: leave as Top level, or configure as you like
Click `Save`

Refresh the page and you should find a new entry in your menus to clear the cache.

# Answer
> 1 votes
There are a variety of methods, but the easiest is probably to download `cv` and use `cv flush`.

---
Tags: cache
---


# Question
Title: Correct method for API calls on contact summary page? (slow!)
I pull out some important at-a-glance information on contact summary pages - membership info, relationships via related cases, etc.

At the moment i override contentsummary.tpl and do my API calls with javascript - page loads, my things fire, then for some, returned values are used in a second API call.

This is slow and feels embarrassingly cludgy!

What *should* i be using for this?

# Answer
Try the Contact Summary Layout Editor that lets you restructure the contact summary. There are a couple of other extensions that link with it that can provide blocks - see the readme.
> 1 votes

# Answer
Have you looked at creating a module extension and using hook\_civicrm\_summary
https://docs.civicrm.org/dev/en/latest/hooks/hook\_civicrm\_summary/

Module creation is described here https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-module
> 1 votes

---
Tags: api, javascript
---


title: Pay later online?

text:
# Question
Title: Pay later online?
I'm using CiviCRM's "pay later" functionality on a contribution page and have received a number of contributions that now have a "pending" status. This is good. When I receive a paper check, I can just update that contribution.

However, some donors wish to fulfill their pay-later pledge *online* instead of by check. **Is there a way for the donor to pay online such that the "pending" contribution will be automatically removed or updated?**

*Note: I am using a thermometer to display the total amount raised and it includes pay-later contributions, which is important to me. I'd like to avoid having duplicate contributions in the thermometer.*

# Answer
> 4 votes
Similar functionality was added as a part of https://issues.civicrm.org/jira/browse/CRM-19263 which should be included in version \>= 4.7.12.

What it includes -

* You need to add a `Default Invoice Payment Page` on `CiviContribute Component Settings`.

* Now any pay later contribution created by a user would contain a `Pay Now` link on `User dashboard` page `/civicrm/user?reset=1`.

* Hitting this button would take you to live contribution page where one can complete the pending contribution using CC details.

More details on the jira issue link.

# Answer
> 1 votes
The payment page has the following URL : .../civicrm/contribute/transact?reset=1&id=12&ccid=251 (where id is the Contribution-Page-Id and ccid is the Contribution-id) (you must force the id).

Being given the contact-id and the contribution-page-id, you can deliver this URL via a small php program (eg : before\_url\_pay.php?c=\[current-user:civicrm-contact:id\]&p=15) which fetches the contribution-id (SELECT id FROM civicrm\_contribution WHERE contribution\_page\_id='.$page.' AND contact\_id='.$contact.' AND contribution\_status\_id!=1), then generates and opens the URL (with ccid = the selected id).

If you use webforms, you can get the contact\_id, and then parameterize the Webform Setting Redirection Location as /sites/default/your\_php\_directory/before\_url\_pay.php?c=\[current-user:civicrm-contact:id\]&p=15 (contrib page id)

Doing that, the user won't even need to pass via the dashboard.

---
Tags: contribution-page, paylater
---


title: Auto add into user group

text:
# Question
Title: Auto add into user group
I created a three group and three organization g1,g2,g3,o1,o2,o3 respectively. I also created a 3 drupal role og1, og2, og3.I assigned these three groups to three user drupal role.I logged in by uesr1 assigned a og1 group. When I am creating a new individual it must add into default group i.e. in g1 group but it is not happening.
My scenario is that when I will create a new individual it must have a default group.  If I add new Individual, it must auto choose a defualt group.

# Answer
It looks like you should be using CiviGroup Roles Sync

You should check the documentation here

https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/group-roles/
> 1 votes

# Answer
Take a look at civirules and see if you can set up a rule so that New Individual gets added to a Group.
> 0 votes

---
Tags: groups
---


# Question
Title: How can we pre-populate contacts into Caldera forms via query params
Title says it all: How can we pre-populate contacts into Caldera forms via query params

# Answer
Michael McAndrew shared a WIP at

https://github.com/mecachisenros/caldera-forms-civicrm/pull/85

* it does not yet include any ACL
* people have to remember to add a hidden contact id to the form
* a dedupe rule where contact id triggers a match (contact\_id weight = 1, threshold = 1) is required
> 4 votes

---
Tags: wordpress, caldera-forms
---


title: Joomla Cron not finding setting files

text:
# Question
Title: Joomla Cron not finding setting files
Running Joomla 3.9.0 Civicrm 5.7.0 PHP 7.0.2

Recently update Civicrm to 5.7.0 - Prior version and my cron job was working fine. Now it hasn't run since November 7th

Run cli.php

`php /var/www/clients/client1/web2/web/administrator/components/com_civicrm/civicrm/bin/cli.php -s domain_name.com -u user -p password -e Job -a execute`

Output is

```
PHP Warning:  include_once(/var/www/clients/client1/web2/web/administrator/components/com_civicrm/civicrm/../..//default/civicrm.settings.php): failed to open stream: No such file or directory in /var/www/clients/client1/web2/web/administrator/components/com_civicrm/civicrm/civicrm.config.php on line 118
PHP Warning:  include_once(): Failed opening '/var/www/clients/client1/web2/web/administrator/components/com_civicrm/civicrm/../..//default/civicrm.settings.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/clients/client1/web2/web/administrator/components/com_civicrm/civicrm/civicrm.config.php on line 118
Could not load the settings file at: /var/www/clients/client1/web2/web/administrator/components/com_civicrm/civicrm/../..//default/civicrm.settings.php

```

I have looked at some of the patches. But the patches are older than the version I have.

Any help would be greatly appreciated. Thank you

# Answer
Check your `administrator/components/com_civicrm/civicrm/civicrm.config.php` file. It should be only 12 lines long and look like the following:

```
<?php
define('CIVICRM_SETTINGS_PATH', '<www root>/administrator/components/com_civicrm/civicrm.settings.php');
$error = @include_once( '<www root>/administrator/components/com_civicrm/civicrm.settings.php' );
if ( $error == false ) {
    echo "Could not load the settings file at: <www root>/administrator/components/com_civicrm/civicrm.settings.php
";
    exit( );
}

// Load class loader
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();

```

The 3 paths to `civicrm.settings.php` within `civicrm.config.php` should all be absolute. Your PHP warnings show that `/../..//default/` is in the path, which is incorrect for Joomla. I can't explain how it (or code that is generating it) ended up in your `civicrm.config.php`; this forum post might give a clue. If your `civicrm.config.php` is not as per the above, replace it with this, substituting with the correct path.
> 0 votes

---
Tags: joomla, cron
---


title: How to attach a File to a Contact?

text:
# Question
Title: How to attach a File to a Contact?
One can attach a file to an Activity, but is it possible to attach a file to a Contact ? How ?

Then, if the file is an image (jpg or png, ...) how to display it ?

(I am using CiviCRM/Drupal + Webform + Views)

# Answer
> 0 votes
If you use webform and views, create a custom field in CIVIcrm, an image field, it will then be available from the Webform interface to be added.

Then select that particular field to be displayed on the view.

# Answer
> 4 votes
One possibility is to use the Documents extension: https://civicrm.org/extensions/documents. This will allow you to add documents to contacts and show them on a separate tab.

# Answer
> 4 votes
A basic option to store a file is to create a custom field of type File. Not sure how well that plays though with webforms/views but easy enough to try.

---
Tags: files
---


# Question
Title: Scheduled Job not executing with wp-cli under cron, but works manually
This wp-cli command executes fine from the command line, but not when run as a cron job.

```
/var/sites/d/mydomain/wp-cli --user=admin --url=https://mydomain/wordpress --path=/var/sites/d/mydomain/public_html/wordpress/ civicrm api job.execute auth=0

```

Any idea where I could start to diagnose this? I have checked the Civi logs in ConfigAndLog, nothing there. I have set php.ini as below

```
log_errors = On
log_errors_max_len = 1024
error_log = /var/sites/d/mydomain/logs/php_error.log

```

But nothing in that log either.

# Answer
To analyse this, as suggested by @Aidan I redirected the cron output to a file by adding this string to the end of the cron command:

```
&> /var/sites/d/mydomain/logs/cron.log

```

This showed that the command was failing with "Fatal error: Class 'Phar' not found in /var/sites/d/mydomain/wp on line 3"

Having queried this with my hosting support, it turned out that the implicit version of PHP called from cron was 5.4, but from SSH terminal, it defaulted to 7.0. Once I explicity called v7.0 php at the front of the cron command as below, it ran fine:

```
/usr/bin/php-7.0 /var/sites/d/mydomain/wp etc

```
> 2 votes

---
Tags: scheduled-job
---


# Question
Title: After upgrade to 5.0.1 - anonymous users can't see any events
The upgrade, in Drupal 7.58, was done some months ago. We have an annual event so I'm only noticing this after trying to set up the new event, but anonymous users can no longer view any events. The error is the following:

Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred. API permission check failed for Event/get call; insufficient permission: require access CiviCRM and access CiviEvent and view event info

There were no changes to permissions, and this worked before. I double checked, and the anonymous access via CiviEvent is still on.

# Answer
I think I figured this out, but it still looks like a bug (sorry I won't probably won't be able to confirm right away and submit a JIRA issues). The Drupal "CiviEvent: Access CiviEvent" seems to need anonymous turned off or anonymous can't view. I had this set because I thought it was necessary, but it isn't for anonymous to view specific events, I think it means to view a listing of events. This still seems like a bug, but I'm glad it's at least working again.

This may also have been the cause for the API permission check failed: CiviEvents Fails after update to 4.7.19 and 4.7.20
> 2 votes

---
Tags: civievent, permissions
---


# Question
Title: Civimail sparkpost extension stats / is my mail being delivered?
We are using the cividesk sparkpost extension on civicrm 5.5.3 and wordpress 4.9.8. In the last few days, we have sent 2 emails to the full list which is about 6,000 emails each, so it should be showing around 12,000. Civimail shows almost all of the mail is successfully delivered. However sparkpost's summary report for the last 7 days shows 167 accepted, 12 bounced, 0 rejected, 256 rendered, and 179 targeted. What do those numbers mean?

# Answer
> 2 votes
Found the answer, thanks @MatthewWire for the hint. Emails were going out using the "backup mailer" defined at civicrm/admin/setting/smtp because we had the wrong API key installed for sparkpost.

---
Tags: civimail, sparkpost
---


# Question
Title: image directory path seems to be ignored in CiviMail editor
G'day,

Using CiviCRM 5.7.2 with Drupal 7.61, when editing a newsletter in CiviMail, the image browser always points me to

```
$drupaldir/sites/all/modules/civicrm/persist/contribute/images/

```

no matter what I configure as the directory path for "Image Directory" at

```
civicrm/admin/setting/path?reset=1

```

I've tried relative path (\[cms.root\]/sites/default/files/uploads), absolute path, and absolute path via settings override in civicrm.settings.php; all to no avail.

\[added to clarify in response to @Chris Burgess' comment\]: The setting does stick, as in it shows up as entered in the form after a reload; and when I tried settings override via civicrm.settings.php, that setting showed up instead and made the form field uneditable. Still, whatever shows up there does not seem to have any impact on where the image browser takes me.

I double- and triple-checked permissions and they are fine; we're also using the same directory with ckEditor and IMCE in Drupal with no problems.

Not sure if I'm missing something, but isn't that the correct setting for what I want to do? Either way, is there a way to point the image browser to our general image path in the drupal files directory?

Many thanks in advance for any advice!

Update: The image browser window shows the following URL:

```
<mywebsite>/sites/all/modules/civicrm/packages/kcfinder/browse.php?cms=civicrm&type=images&CKEditor=crmUild_1&CKEditorFuncNum=0&langCode=en-au

```

so I poked around a bit in the `kcfinder` directory. There's a `config.php`, but it appears that the settings in there are also ignored.

So I took more desperate measures:

```
cd $drupaldir/sites/all/modules/civicrm/persist/contribute
mv images images.HOLD; ln -s ../../../../../default/files/uploads images

```

Now it shows me the correct directory (though with the wrong name), but whatever I try to do, I get a "warning" dialog stating "unknown error". Well, was worth a try.

Anything else I could try to get this to work?

# Answer
> 3 votes
Ok, I've worked it out. And it turns out that there *is* a location where CKEditor settings can be configured, namely at `civicrm/admin/ckeditor?preset=default`. (Through the GUI it's at "Administer" -\> "System Settings" -\> "Display Preferences", then click the "Configure CKEditor" button towards the bottom.)

There are a few hitches on the way and perhaps this comes in useful for someone else down the track:

* the image directory *must* be called `images` for the CiviMail browser to work with it;
* the image upload directory setting in CiviCRM needs to point to the parent directory of that `images` dir; in my case it is `[cms.root]/sites/default/files/`;
* the setting to override in the CKEditor settings is `ImageUploadURL`, which also needs to point at the parent dir of `images`. A local path works - I used `/sites/default/files`.
* turns out that that alone didn't do the trick (I could browse the correct directory, but the browser would then return the wrong URL string); I also needed to override the setting in `civicrm.settings.php` like so (look for `$civicrm_setting` to find the examples):

$civicrm\_setting\['URL Preferences'\]\['imageUploadURL'\] = '/sites/default/files';

And that's it!

Now for this naming requirement.

In my case, we have been keeping all our images organised in a directory called `uploads`, and the image browser clearly had a problem with symbolic links. So what I did is

```
mv uploads images
ln -s images uploads

```

Aka rename `uploads` to `images`, then create a symbolic link named `uploads`. Then reconfigure IMCE in Drupal to now use the `images` folder. (It seemed to keep working just fine with the symbolic link, but we want to keep things clean.)

NB: In my case, the site is hosted on a cPanel with no ssh access, so I did the renaming through the GUI and then created a cronjob to run the second command (here at 19:45h, and don't forget to delete it again) like so:

```
45  19  *   *   *   ln -s images /path/to/drupal/sites/default/files/uploads

```

As a result, all images now live in `$drupaldir/sites/default/files/images` and both, IMCE in Drupal, and kceditor/ckeditor/whateveritis in CiviMail, now work with it, referencing the same files. Yay!

Meanwhile, Apache seems happy to resolve across the symlink, hence all existing URLs keep working, though it'd be nice to clean them up over time.

(Not a straight-forward search/replace through the database, unfortunately, as the two strings have different lengths. If they were the same length, that'd be simple.)

---
Tags: civimail, ckeditor, images, directory
---


# Question
Title: How can I alter DataTable defaults / attributes without overriding core files?
Example use case:

When viewing a Contact, on the Relationships tab we'd like the DataTables to default to showing 50 records.

# Answer
> 2 votes
You can alter any DataTable table through it's API as long as you are in Civi's jQuery context (CRM.$)

You could use hook\_civicrm\_alterTemplateFile or hook\_civicrm\_buildForm for example to load your script:

```
Civi::resources()->addScriptFile( 'my-extension', 'js/alterDataTables.js' );

```

Then in your js:

```
// alterDataTables.js file
CRM.$( function( $ ) {
  // get and itarate over all dataTables
  $( '.dataTable' ).map( function( index, table ) {
    // get dataTable instance
    $( table ).DataTable()
      // set page length
      .page.len( 2 )
      // draw table
      .draw()
  } );
} );

```

The above example was given to me so may have worked in some places e.g. when the dataTable is available on page load. For my use-case I needed to work with the 'Relationships' tab tables when viewing a Contact. In this case, $('.dataTable') would select nothing unless I responded to the ajax event, in which case I also needed to add once() to avoid an infinite loop of redrawing tables:

```
CRM.$(function($) {
  $(document).ajaxComplete(function() {
    var dt = $('.dataTable');
    if (dt.length) {
      $('.dataTable').once().map(function(index, table) {
        // get dataTable instance
        $(table).once().DataTable()
          // set page length
          .page.len(50)
          // draw table
          .draw()
      });
    }
  });
});

```

---
Tags: datatables
---


# Question
Title: process_mailing processing addresses when called in UI but not CRON
CiviMail scheduled e-mails are not being triggered automatically through CRON. Using the same user with the same permissions, I get the following in the log when triggered through the Scheduled Jobs user interface:

```
Parameters parsed (and passed to API method):
a:1:{s:7:"version";i:3;}

Full message:
Finished execution of Send Scheduled Mailings with result: Success (a:1:
{s:9:"processed";i:1;})

```

But when the same is triggered on CRON using CURL

```
Parameters parsed (and passed to API method):
a:1:{s:7:"version";i:3;}

Full message:
Finished execution of Send Scheduled Mailings with result: Success (a:1:
{s:9:"processed";i:0;}

```

I'm not getting any errors when I call the CRON page from the browser. On the CiviCRM status page it shows that CRON is running. In conclusion, the scheduled task processes address only from the user interface and not from CRON.

I am using the latest CiviCRM build (5.3.1).

# Answer
Had the same problem, on Ubuntu change the system time zone with "sudo dpkg-reconfigure tzdata". Restart the mysql service with "sudo service mysql restart".

Can confirm that this gets the cron running and processing the mailing.
> 3 votes

# Answer
I figured out that it was due to a time zone setting mismatch between MariaDB and PHP. Taking inspiration in this forum post https://forum.civicrm.org/index.php%3Ftopic=26132.0.html, I observed that the time zone settings on the server were different than in the database. My workaround was as follows:

1. On Drupal, I disabled the option to allow users to select their own time zones and made sure that America/New York was selected
2. On my server (I have CentOS 7 running) I selected the time zone

```
sudo timedatectl set-timezone America/New_York

```
3. Afterwards I logged in to MySQL and noticed that the time zone was still incorrect

```
mysql> select now();

```
4. I restarted the MariaDB service on my server

```
sudo systemctl restart mariadb

```
5. I logged in to MySQL again and confirmed that the hour matched my time zone settings
6. I ran again the command from SSH using both curl and cv (see here for details on how to set that up: https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/)
7. I finally confirmed that the scheduled e-mails were triggered as intended

I hope this solution can help others solve this otherwise tricky workaround. My intuition was based on the fact that the CRON job itself was not failing, and my user had all the correct Drupal permissions (I verified by logging in and checking to see if all contacts were visible).
> 2 votes

---
Tags: civimail, cron-job, cron, mailing
---


title: Hosting Provider for CiviCRM

text:
# Question
Title: Hosting Provider for CiviCRM
I am trying to install my CiviCRM instance on my current drupal installation that is my website which is hosted by the webgo24.de. During installation I get an error „DB Error“ and after some emails between my Hoster and me he came back with the info that the required permissions I need for the database for CiviCRM are Admin permissions and they can‘t give me those.

Do you have an idea on how to solve that in general? Is there a smaller version that does not require all the rights? How are you setting up CiviCRM? Own server, cloud server or root server with Hoster?

Thanks for your help? Said

# Answer
> 3 votes
You can find the list of required permissions here: https://docs.civicrm.org/sysadmin/en/latest/requirements/#mysql-permissions

You might want to check out some of the options for hosting here https://civicrm.org/partners-contributors?country\_1=All&services=Hosting&language=All&cms=All

# Answer
> 0 votes
If you're able to set up Drupal on the server, then you probably already have the needed permissions since Drupal has it's own database which can also be used for CiviCRM. Did you set up Drupal yourself, or was it prepackaged?

---
Tags: database, permissions, installation, hosting-providers
---


# Question
Title: Upgraded php from 5.6.30 to 7.0.32, civicrm still gives PHP out of date error
I upgraded php from 5.6.30-0+deb8u1 to 7.0.32-1~dotdeb+8.1 and civicrm is still giving me a php out of date error.

When I run php -v it says 7.0, but civicrm still thinks I'm on 5.6.

Do I need to purge php 5.6 if php -v tells me I upgraded to 7.0?

# Answer
It depends on your hosting server. It is usually possible to specify different PHP versions for command line (eg. php -v) and php that is used by your web server. If you have no need for PHP 5.6 then I suggest you remove it and that trigger everything to use PHP 7.0. Otherwise you'll need to look at your webserver/php configuration to make sure PHP 7.0 is selected as default. Also, worth noting that PHP 7.0 is end of life soon, worth going to PHP 7.1 if available.
> 4 votes

# Answer
OK, so 2 steps

1. Disable php5 and enable php7 in apache sudo a2dismod php5 sudo a2enmod php7 (maybe php7.0 sudo service apache2 restart
2. civicrm needed me to install a few php extensions -

sudo apt-get install php-xml php7.0-gd php7.0-imap php7.0-mbstring memcache php-curl

sudo service apache2 restart

pretty much did the trick.
> 1 votes

---
Tags: error, php
---


# Question
Title: civicrm dropdown list not appearing on the same popup but underneath pop-up's layer
i am having a strange issue . 1.when i click on any drop-down , list does not show on the same place , but appears beneath the pop-up/ or the dropdown's layer. here is the screen shot, what's wrong i am not able to figure out.

# Answer
> 2 votes
We are having the same problem and its annoying as we can't added Shortcodes. Another post from 2016 found it was a CSS conflict with Slider Revolution.

Dropdowns in the admin area appear underneath the modal window.

Using the Function snippet didn't fix the problem for us or changing the CSS.

One hack around this that works for us is:

1. Click the dropdown
2. Move drag the pop-up box to one side to see what the dropdown displays
3. Click the dropdown again to close it
4. Click the dropdown once more
5. Use the curser keys to select your dropdown option
6. Hit the Enter key on your keyboard to select the dropdown option.

# Answer
> 0 votes
Do you possibly have a custom css stylesheet set up for Civi? I'd try inspecting the window to see if there is a style conflict.

---
Tags: wordpress, civicontribute
---


# Question
Title: Add "sender/from" line to postal mailing labels
I like to add a "from" line at the mailing label so we can use cheaper blank envelopes and am looking for the location and filename of the stylesheet of the labels. If I do it in Administer - Localization - Address Settings the font for the sender is to big.

Like:

consigner/sender | xystreet 12 | zip town

---

recipient Name

Street

ZIP town

I have checked documentation but could only found how to add physical formats so far. Thank you for your tipps!

SECOND is there a way to define a start position, having a sheet that is patially used? e.g. start at label 5 or start at row2, label 2

# Answer
> 4 votes
My solution for Question 1:

I create labels with the recipients in CiviCRM and save it. Than i create a label-sheet with the same format in libre-office only with the "from"-line and safe it as pdf. then i use "pdf chain" (for linux) to merge this two files together. in "pdf chain" it called "backround/stamp". so it "stamps the "from"-pdf as often as needed in to the pdf from CiviCRM.

# Answer
> 1 votes
As an alternative to pdfchain, this can easily be done using pdftk:

> pdftk MailingLabels\_CiviCRM.pdf multistamp pdfstamp.pdf output out.pdf

The only thing you need, is a pdf file (maybe created using LibreOffice) that can be used as the "stamp" for the whole page of mailing labels.

---
Tags: address-labels
---


title: Problem with process_mailing

text:
# Question
Title: Problem with process_mailing
Using Drupal 7 and Civi 5.7.0

When sending batch emails using CiviMail, if I select "Administer CiviCRM » Scheduled Jobs" and select "Process now" on the "Send Scheduled Mailings" job then the mailing sends successfully. If I allow the cron to execute the same job, then I'm getting an SMTP error ("Failed to set sender" and "authentication failure") and the mailing fails. The log entries for the two jobs are identical. The SMTP settings are correct. The user specified in the cron job is the same as the one I'm using to "Process now".

Note: I recently dealt with the time zone error described in process\_mailing processing addresses when called in UI but not CRON This got my cron running the process\_mailing job but now I'm getting the SMTP error. The only change I made was to set the timezone on the server to the same as Drupal.

# Answer
OK, the answer turns out to be a matter of capitalization. I'm using the cv addon (https://github.com/civicrm/cv) to send the command "job.execute" from cron. My cron line looks like:

```
cv api job.execute --user=username --cwd=/var/www/html/sites/default

```

However, my username on the server is not capitalized while my Username in Drupal IS capitalized. When I changed the cron to "--user=Username" all is well. It is interesting that the cron WAS executing and that the commands were being fired, thus the entries in the CiviCRM logs. However, since Drupal was seeing "username" as an unauthenticated user without the authority to send email, even though the process\_mailing command was working, SMTP was failing.
> 1 votes

---
Tags: civimail, cron
---


title: CV Scheduled jobs not firing from cron

text:
# Question
Title: CV Scheduled jobs not firing from cron
I am attempting to use CV to call job.execute to run my scheduled tasks as described in the CiviCRM Documentation. I am using Drupal 7. I have several independent sites running on the server.

It works fine when I call it manually (for each site):

```
sudo cv api job.execute --user=admin --cwd=/var/www/html/siteroot

```

The tasks also work when I call them manually from the UI (for all sites)

Crontab is set up with the following:

```
*/5 * * * * cv api job.execute --user=admin --cwd=/var/www/html/siteroot

```

the syslog shows no problems and that the cron fires (example output):

```
Nov  1 10:15:01 live CRON[8991]: (root) CMD (cv api job.execute --user=admin --cwd=/var/www/html/siteroot)

```

However,

the scheduled tasks appear to not be running. I have configured several to run "whenever cron is run" but they still do not run unless I fire them manually.

Is there something I am missing? Is there a log in Civi where I can see if the command is being received?

I am using Drupal 7, php7.0, CiviCRM 5.3 on Ubuntu 16.04

# Answer
> 4 votes
Ok so this may seem like a silly issue to some but after some messing around I figured out cron didn't have access to the path where CV was installed so to fix it the crontab entry had to be changed to:

```
*/5 * * * * /usr/local/bin/cv api job.execute --user=admin --cwd=/var/www/html/siteroot

```

There was no error as the mailer deamon was not firing correctly so no error was being sent or logged.

Cron does not generally have access to the path that a shell root user does, which is why running the command `cv` as root works just fine.

# Answer
> 1 votes
Is the user "admin" defined in Drupal? If not some commands will not fire under cv. cv needs a user under "username" that is recognized by Drupal as having the rights to fire the command you're interested in. I had this same issue myself which was fixed by identifying an authorized Drupal user.

---
Tags: cron-job, scheduled-job, cv, sysadmin
---


# Question
Title: Error loading module file () - Wordpress
I have just upgraded a CiviCRM install on Wordpress. Went from Civi 4.5x to 4.6.5. The site uses L10n (EN / FR).

I had two error messages when I first finished the upgrade. One was:

"civicrm Unknown extension: net.ourpowerbase.sumfields"

That one seems to have resolved itself.

The other is: "Error loading module file (). Please restore the file or disable the module."

This error appears both in the admin area of CiviCRM and on the front end where profile forms are used.

I have no idea where to start looking to fix this! I found one post about drupal, but that didn't help.

Any assistance would be greatly appreciated.

Thank you.

# Answer
> 5 votes
This typically happens when either a) an extension is deleted, or b) the location of the extension changes.

First, make the easy fix. Go to **Administer menu \> System Settings \> Cleanup Caches and Update Paths**. Press "Clear Caches", and reload the page TWICE. Hopefully that fixes the error. If not - check that page and make sure the paths are 100% correct.

If that doesn't work, go to **Administer menu \> System Settings \> Manage Extensions** and look for anything amiss. Take special note of missing extensions - see if they're actually missing in the file system.

This should get you all cleaned up, or at least on the right track!

# Answer
> 2 votes
I had the "Error loading module" issue with Civi 5.x/Joomla 3.8x. This message was appearing before most front-end content. The suggestions above led me to disable then re-enable extensions that had been installed with git clone (namely Mosaico 2.0b & related). This cured the problem.

---
Tags: upgrade
---


# Question
Title: How to Mark CiviCRM checkbox field not required programmatically?
```
add_filter('civicrm_buildForm','contact_mark_t_fields_optional',10,2);
function contact_mark_t_fields_optional($formName, &$form){
    if($formName == 'CRM_Contact_Form_Contact'){

        $user = wp_get_current_user();
        $is_admin = FALSE;
        foreach($user->roles as $k =>$v){
            if($v == 'administrator'){
                $is_admin = TRUE;
            }
        }
        if ($is_admin){
            //Array ( [0] => custom_2_-1 [1] => custom_3_-1 [2] => custom_4_-1 [3] => custom_5_-1 [4] => custom_6_-1 [5] => custom_7_-1 [6] => custom_8_-1 [7] => custom_11_-1 [8] => custom_12_-1 [9] => custom_13_-1 [10] => custom_14_-1 [11] => custom_15_-1 )//
            $optional = array(
                'custom_2_-1','custom_3_-1','custom_4_-1','custom_5_-1','custom_6_-1','custom_7_-1',
                'custom_8_-1','custom_11_-1','custom_12_-1','custom_13_-1','custom_14_-1','custom_15_-1','custom_41_-1'
            );
            foreach($form->_required as $k => $v){
                if (in_array($v, $optional)){
                    unset($form->_required[$k]);
                }

            }
        }

    }

}

```

I am trying to mark a checkbox field as optional programmatically when an admin views from the admin side, but while trying to save it, it gives a "Field Required Error"

# Answer
> 4 votes
You can use validateForm hook to empty the errors on the input field. Eg

```
function hook_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
  if (your_condition_statement) {
    $form->setElementError('field_id', NULL);
  }
}

```

Also note that as this looks like a custom field, civi also provides a UI setting to disable the `required` attribute. Screenshot from `Add/Edit custom field` form.

# Answer
> 0 votes
Jitendra's answer is good. I also like the Profile Conditionals extension by Joinery. It only supports event and contribution pages at present, though it shouldn't be hard to extend it to work on others.

---
Tags: wordpress
---


# Question
Title: How to retrieve custom field image files?
How can I retrieve images uploaded in custom field sets for contacts? Could you get a URL for them the same way you can for the contact "image\_url" in the API?

When I look up the custom field for the file in the API, it just returns a number. I looked at the code docs for the Attachment entity in the API, but this seems to be more suited for non-image files, unless I'm mistaken. I am looking to call the API and display these images on a web page.

I'd appreciate any help I can get, thanks.

# Answer
> 2 votes
Without more context about what the API call you're making is, I can't say why it just returns a number. Here's what happens when I call the API from my command line to get the results of the attachment with an ID of 1:

```
» cv api attachment.get id=1
{
    "is_error": 0,
    "version": 3,
    "count": 1,
    "id": 1,
    "values": {
        "1": {
            "id": "1",
            "name": "Project_Properties_dmaster_677.png",
            "mime_type": "image/png",
            "description": "",
            "upload_date": "2018-11-27 22:19:47",
            "entity_table": "civicrm_activity",
            "entity_id": "628",
            "icon": "fa-file-image-o",
            "created_id": "",
            "url": "http://dmaster.localhost/civicrm/file?reset=1&id=1&eid=628",
            "path": "/home/jon/local/civicrm-buildkit/build/dmaster/sites/default/files/civicrm/custom//Project_Properties_dmaster_677_ab277eebda5f50aeb9910018ab356f34.png"
        }
    }
}

```

It returns the URL property which I can output in an HTML file within an `<img>` tag to display the image on a web page.

---
Tags: custom-fields, api, images
---


# Question
Title: Net amount not calculating for event registration
Civicrm 5.7.0/Wordpress 4.9.8:

When I manually enter an **event registration** that needs a payment processor fee, prior to civicrm upgrade to 5.7.0 from 4.7.19, there was an area at the bottom of the form called "Additional Details". In that section I could enter the processor fee amount and the net amount would be automatically calculated. In 5.7.0 that section is now gone. After I complete the registration I can go to the contact's profile and edit the corresponding Contribution where the Additional Details still exist although the net amount field beneath the fee is missing (Perhaps because of the changes listed at https://civicrm.org/blog/dev-team/civicrm-56-release). When I enter the processor fee amount the net amount is not calculated in reports. Event registration reports will show registration fee, processor fee amount, and net amount but the net is not gross (reg fee) minus processor fee. It replicates the gross amount.

This does not happen when entering a contribution only, just when registering for an event. I have on rare occasions seen this happen on previous version when someone has used our online registration page but maybe only three or four times out of 100 registrants. I would then have to delete the transaction and rebuild it manually in order to get the processor fee to show up and calculate the net. Under the circumstances listed above that will no longer be possible.

Has anyone else experienced this and have a fix? I have tried turning off custom fields and activated past events all with the same results. Also, NO event reports show the correct calculation as described above.

# Answer
Welcome! Thanks for reporting that. As you noted, in 5.6 the net amount is not displayed on those forms now since it was being automatically calculated anyway. I have recreated your issue and it seems to be related to contributions generally rather than specifically related to events. The net amount is being calculated correctly when the contribution is first created but edits to the fee amount are not causing re-calculation of the net amount. I have created an issue here: https://lab.civicrm.org/dev/core/issues/552
> 1 votes

---
Tags: civievent, registration, reports
---


# Question
Title: Eway recurring - Any method to record invoice reference and description?
Eway provides a way to add invoice ref and description by adding params like `InvoiceDescription` and `InvoiceReference` in `alterPaymentProcessorParams` hook provided by civicrm.

Unfortunately this does not work for recurring payments.

Eway does not seem to provide any flexibility to set `Invoice reference` or `Invoice Description` for a recurring payment. See the parameter that could be set - https://eway.io/api-v3/#recurring-payments.

Any thoughts for an alternative way to set these field values?

We are using Eway recurring extension to record payments in civi - https://civicrm.org/extensions/eway-recurring-payment-processor

# Answer
> 2 votes
ok - this has fixed for us and the reason was the incorrect param sent to the ProcessPayment operation. The correct way of sending the invoice params is -

```
$client = CRM_Core_Payment_EwayUtils::getClient($params['payment_processor_id']);
$endPoint = 'https://www.eway.com.au/gateway/managedpayment/ProcessPayment';

$paymentInfo = array(
  'man:managedCustomerID' => $params['managed_customer_id'],
  'man:amount' => $params['amount_in_cents'],
  'man:invoiceReference' => $params['invoice_id'],
  'man:invoiceDescription' => $params['description'],
);
$result = $client->call('man:ProcessPayment', $paymentInfo, '', $endPoint);

```

Note the correct usage of `man:invoiceReference` and `man:invoiceDescription`. It should be case-sensitive.

---
Tags: recurring-contributions, eway
---


title: No address marked as Primary

text:
# Question
Title: No address marked as Primary
I need to pull a list of members who has no primary address ticked. Has anyone any idea on how I can do this?

When our data came over from our old membership system it took over the addresses but some are not marked as primary and I am trying to find those ones by pulling a list. Thanks

Thanks,

Eileen

# Answer
> 1 votes
Thanks for the additional explanation! One approach you could try is to use Search Builder (Search \> Search Builder) and search for contacts whose primary street address is null but whose street address of your default location type (e.g., Main or Home) is not null. If that doesn't yield the results you want, then you could search for your other location types as well (e.g., where primary street address is null and (Location Type A street address is not null or Location Type B street address is not null or Location Type C street address is not null)).

---
Tags: addresses, primary
---


# Question
Title: Jquery not affecting custom fields of an activity
I have written some jquery (inside an extra template file) that does some simple show/hiding of custom fields in an activity based on user selections. We use it as a helpful tool for users to select the *right* options (i.e. Do you own a pet? If they indicate "yes" then the Pet Name field is shown.)

This is currently working in 4.6.8 (Drupal 7) but in my test upgrade to 5.5.3 the jQuery targets aren't affecting the custom data sets. For instance, I can try targeting something generic like `'.crm-container .crm-accordion-header'` and for testing purposes turn it blue. This affects the headers for the core sections (attachments, send a copy, send a follow up) but the headers for my custom data remain unaffected.

Is there a fundamental change in how/when the custom fields are loaded that the jQuery isn't able to affect it?

EDIT: I have also tried adding the javascript straight into a template file (no "extra") in the overrides folder, still custom fields are unaffected. I also placed javascript directly in the main template file, not in the overrides folder - still custom fields are not affected.

```
{literal}
<script type="text/javascript">

CRM.$(function($) {
  $(document).ready(function () {

    // First, get the Activity ID.
    var acttype =  {/literal}{$atype}{literal}

    if(acttype === 75){
        $('.crm-container .crm-accordion-header').css('background-color', 'blue');
    }
  });
});

</script>
{/literal}

```

# Answer
> 3 votes
In *some* CiviCRM pages/forms custom fields are loaded/reloaded via AJAX (you will notice that if you have a set of custom fields based on Activity type, the custom fields update/reload when changing the Activity type to show its correspondent set of custom field).

With that in mind you should trigger you script on .ajaxComplete(), something along those lines:

```
CRM.$( function( $ ) {
    $( document ).ajaxComplete( function( event, xhr, settings ) { // optional params if you need to differenciate between events/requests
        // do stuff
    }
} )

```

# Answer
> 2 votes
Ok What's happening is this. If you look at your .crm-accordion-header css rules in an Inspector window in your browser, you will see there is a background-color !important rule earlier in the CSS cascade that is overriding anything you do in jQuery. I was testing this in the Console and drove me nuts too.

jQuery does not recognise !important using .css so you cannot override it in that way. I tried defining a new class .importantClass and using addClass to add it in, but that failed too.

So what you need to do is find the offending line in the CSS file and remove the !important bit and all will be well.

---
Tags: javascript, custom-templates
---


# Question
Title: CiviReport 'insufficient permission' error running financial report after update to 4.7.29
Only since upgrading CiviCRM to 4.7.29 from 4.7.11 (on Drupal), one of my users with 'editor' role is unable to run a financial report. The error she sees is:

```
"API permission check failed for FinancialAccount/get call;
insufficient permission: require administer CiviCRM"

```

I can't believe she should need full admin rights just to run this report. On 4.7.11 it wasn't necessary.

Is there a recommended way to investigate the error and see whether assigning a lesser permission to the 'editor' role would restore normal service? The upgrade process warned of a new permission 'manage tags' but nothing to do with Financial Accounts or CiviContribute.

# Answer
This bug has been reported at Bookkeeping Transactions Report insufficient permissions and from CiviCRM 5.9 will be fixed. Here the affected code.
> 1 votes

---
Tags: civireport, 4.7, permissions, roles
---


# Question
Title: Contribution page validation errors display and confirmation screen switch to default language instead of remaining in the current language
When using a contribution form in French with the confirmation page enabled, the page redirects to the English confirmation page url instead of the French.

Start here: https://domain.ca/fr/civicrm/contribute/transact?reset=1&id=\[cid\]

End here: https://domain.ca/en/civicrm/contribute/transact?\_qf\_Confirm\_display=true&qfKey=\[key\]

If I manually switch to the French url, everything looks OK, but if you hit the CiviCRM 'go back' button, it will take you back but switch to English again.

Similarly, if you attempt to go to the confirmation page but the form doesn't validate, while the URL doesn't change, the contents switch to English - all except for price set options (price set labels and help text are in English though).

This is our set-up:

* Drupal 7 with language detection based on url language prefix (en, or fr)
* Multilingual site using CiviCRM 5.6.1 (latest at time of writing)
* 'Inherit CMS Language' is enabled
* Default language is en\_CA, secondary language is fr\_CA

Extension enabled:

* iATS Payments
* Summary Fields
* ExtendedReport
* CiviDiscount

The bilingual demo site is currently out of date so I've been unable to confirm if this is just us or 5.6.x in general.

# Answer
This was a configuration error on our part. Clean URLs was not fully functional - the language prefix was missing from the beginning of non-clean URLs so the final URLs were resolving to only the default language.

Adding `$conf['clean_url'] = 1;` to the settings file resolves the issue.

Thank you @bgm for helping with the demo site so that we could narrow this down to an issue with our site specifically.
> 1 votes

# Answer
Are you using the Canadian Tax Receipts extension?

If so, can you test this patch: https://github.com/jake-mw/CDNTaxReceipts/pull/86 ?
> 0 votes

---
Tags: contribution-page, translation
---


# Question
Title: How to target a specific event type in a system workflow message
We'd like to separate the receipt for signing up for events by the event type - an email for one specific type and another one for all the other events. However, I haven't figured out how to specifically target it yet.

Right now we have something that looks like this:

```
{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}

     some text...

{else}

     some more text

     {$event.confirm_email_text|htmlize}

{/if}

```

Thanks!

# Answer
> 2 votes
I think you can use the `event_type_id` token inside the event templates. Something like -

```
{if $event.event_type_id == <id of the event type>}

  text for the specific event type

{else}

  common text for all other events

{/if}

```

---
Tags: civievent, civimail, system-workflow-messages
---


# Question
Title: Unintentional removed CiviCRM compnents in Joomla, Re-Installation fails
Joomla 3.9.1 - CiviCRM 5.7.2

Hallo Community,

I wanted to remove the CiviCRM components from a test site. Unfortunately I picked the wrong TAB (Test and live have very similar names) and removed the CiviCRM components from the "life" site.

I already checked the D/B. All tables are still in place.

When I try to reinstall civicrm components from joomla\_site\_root/tmp/com\_civicrm the process seems to start, but followed by a blank page.

Is there any other way to recover CiviCRM without performing a complete backup. My last backup is about two weeks old, but we had a lot of data updates in this time.

Thank you for any hint!

Bert

# Answer
Have you deleted /media/civicrm/templates\_c? That's where Civi caches pages and can be a cause of white screen of doom. You could maybe try deleting/moving the entire media/civicrm directory (saving any files or extensions you've uploaded there) before installing. If that still doesn't help maybe try emptying the dbse tables:

```
civicrm_acl_cache
civicrm_acl_contact_cache
civicrm_cache
civicrm_group_contact_cache

```

If none of that works - then maybe you could try creating a new install of CiviCRM to a new database (making sure it's the same version as the one you deleted) and then change the dbse settings in

```
/components/com_civicrm/civicrm.settings.php
/administrator/components/com_civicrm/civicrm.settings.php

```

to point to your old dbse (and then deleting the templates\_c directory again)
> 0 votes

---
Tags: joomla, install
---


# Question
Title: How do I control the order in which hooks fire?
If I have two extensions that both use, say, `hook_civicrm_post`, how can I control the order in which the two extensions fire?

# Answer
> 0 votes
My original answer in 2016 is now out of date. In Civi 4.7.19+, you can control the order of hooks with the Symfony EventDispatcher.

# Answer
> 2 votes
CRM/Utils/Hook.php indirectly calls CRM/Extension/Mapper.php::getActiveModuleFiles which does

SELECT full\_name, file FROM civicrm\_extension WHERE is\_active = 1 AND type = "module"

So there is no well-defined order. You could of course hack that line to add an ORDER BY.

# Answer
> 1 votes
I got some great answers on Mattermost.

Frank Gomez of Ginkgo Street Labs says: We've developed an approach (which you may find heavy handed) to dealing with order of operation problems when it comes to hook\_civicrm\_post. In our case the problem was not the order in which extensions were firing it but rather that dependent entities might not exist yet. Basically the approach is to defer execution of the code by creating a queue item to deal with it on the next page load, when the dependent entities are expected to have been created.

Here's the repo: https://github.com/ginkgostreet/com.ginkgostreet.listener.

Allen Shaw of Joinery points to Tim Otten's post here, the most notable part is: \[You can't\] - in fact, I suspect the order is non-deterministic, with a slight bias towards installation-order (ie the extension which was installed first would tend to run first). I came to this belief from tracing CRM\_Utils\_Hook::commonInvoke() =\> commonBuildModuleList() =\> requireCiviModules() ...etc... finally arriving at CRM\_Extension\_Mapper::getActiveModuleFiles(), which queries the DB and does not have an ORDER BY.

# Answer
> 0 votes
I am not sure if you can, perhaps by making sure the sequence is as you would want in civicrm\_system?

Can you explain a little about what you want to do so I can perhaps come up with another alternative (you never know....)

---
Tags: developer, hooks
---


# Question
Title: How to record a webform submission ID in a CiviCRM field?
I'm using a webform to collect applications for an accreditation scheme. Usefully the webform submissions each have a unique submission ID that I can include in the webform-driven email notifications that get sent. And using webform-civicrm integration I can collect the data from the webform submission into CiviCRM for ongoing workflow.

What I want to do is to record the webform submission ID into a custom field in CiviCRM at the same time, so that I can then use it in further email notifications to the people involved. But the \[submission\] tokens are not available for form components - because the form isn't yet submitted so the values aren't available.

Any way to do this? Or alternatively create a unique ID number in CiviCRM, and then maybe use CiviRules to generate all of the emails?

It seems like such a trivial thing to have a unique reference number, but in Civi the only thing I can see that's useful is a Case ID number and I'd really rather not have to use cases for what is otherwise a very simple process.

# Answer
> 3 votes
there is an extension that allows you to create a CiviRule with trigger webform is submitted: https://github.com/CiviCooP/org.civicoop.civiruleswebform. That might help you, although you probably then still have to create a little CiviRule action that stores the submission ID in the CiviCRM custom field.

Drop me a mail if you want to take this further?

# Answer
> 1 votes
How about this for a unique-reference number:

CRMID-Number is a CiviCRM Custom field - Alphanumeric - Text I've made it: \[node:nid\]-\[random:number\]-\[current-date:raw\]

node id = 421 random number = 758398555 data raw is UNIX timestamp = 1543593293

---
Tags: webform-civicrm
---


# Question
Title: Where do I adjust the auto logout duration for administrators?
This is my first time asking a question about CiviCRM and am not sure if I am even in the right place.

# Answer
User access is done by CMS so it isn't really a Civi question. If you are on WP, you can use this https://wordpress.org/plugins/inactive-logout/. If other CMS, post on their forum.
> 1 votes

---
Tags: permissions
---


# Question
Title: CiviCRM profile search not working when integrated with Wordpress
We're currently facing an issue. We are running Wordpress 4.9.8, and running CiviCRM. We're looking to publicly display a search widget on one of our wordpress pages, to search within a specific profile we have created. For background, this is how the process works: Client fills out an application (Caldera Form), that form is processed and put in CiviCRM. We then go to each application and change each one to the contact type "Approved", which puts them into a Smart Group for only approved organizations. This approval system is so we can control which organizations are publicly displayed on the website. We then have made a profile with the specific contact information we want to display, and we have limited the profile listings to the specific "Approved" smart group.

Here's our issue: The search box appears publicly on our wordpress website, but any time someone attempts any search, the user is redirected to either a completely blank page (firefox) or a page with an HTTP 500 error (Chrome). The Url for this website follows this format, in case it's relevant: ....wordpress.org/..../?page=CiviCRM&q=civicrm/profile .

Here are some troubleshooting steps we've attempted and clarifying information to make help easier:

* The Profile has "Standalone Form Or Directory", "Search Views", and "Is the CiviCRM profile active" all selected
* The Profile's listings are limited to a specific Smart Group, in this case, the "Approved" Smart Group
* This Smart Group has "Expose Publically" selected
* Smart Group Visibility is set to "Public Pages"
* Smart Group has "is active" selected
* The Smart Group definitely has contacts in it, so it is not empty
* The Search does not work in any situation, whether or not we put in search parameters or not
* The error we get is "HTTP Error 500"

Any help you can provide would be greatly appreciated. Thanks in advance.

# Answer
Check your Permissions. There is a specific permission for seeing Listings.

> CiviCRM: profile listings Warning: Give to trusted roles only; this permission has privacy implications. Access public searchable directories.
> 1 votes

# Answer
A 500 error generally indicates a PHP error. You can check your PHP error logs (which are probably the same as your web error logs unless you're doing something fancy) for more information. If that solves your problem, great! Just come back here and mark this as the solution. If this did NOT solve your problem, edit your original question to include the error you see that corresponds to the 500 error.
> 1 votes

---
Tags: wordpress, profile, search, smartgroups
---


# Question
Title: Disable Debit Card Payment Method option
It looks like I can not disable the Debit Card option in CiviCRM.

It is safe to disable this option in the database? Is there another option?

# Answer
> 2 votes
These are reserved payment option to which civicrm does not provide an option to disable or delete them.

Would recommend to first disable it from a development site database since this might result in an unnecessary fatal error as civi expects it to be available in multiple places. If you don't see any error - you can just repeat it on live.

---
Tags: civicontribute
---


# Question
Title: Different Contacts of same child Group in multisite
I use a multi-site CiviCRM installation with the CiviCRM Multisite extension installed and tuned : having Multi Site Configuration enabled and each site set with a Domain Group. I set all the proper user's roles in the Drupal permission page for each domain (use of domain access in Drupal 7).

But I struggle with the use of sub-groups.

Let's consider that for the site A-site, the Domain Group is A-group, and for B-site the Domain is Group B-group. Both A-group and B-group are parent group for a same child group C-group.

In one exemple that I have, a C-group that is shared group between different two sites shows a very different number of contacts : one gives 1488 Contacts and the other only 42 Contacts…

**Site A** \> Domain Group is **A-group** \> is parent of **C-group** \> **1488 contacts**

**Site B** \> Domain Group is **B-group** \> is parent of **C-group** \> **42 contacts** (The site B has no access to the missing 1446 contacts)

I cannot explain why there is a difference of contacts that belongs to C-group depending on they are on the A-site or the B-site.

The 42 contacts belongs both to B-group and C-group, the missing 1488 Contacts belong only to C-group.

The CiviCRM Multisite doesn't consider a shared sub-group between sites ? What is the criteria for a contact to belong to a site or another ? Should I understand that to belong to a (same) sub-group is not the condition to belong to a site ?

Is there a way to include in the selection process the use of sub-groups (child groups) ?

# Answer
> 2 votes
We totally gave up on using sub-groups with the CiviCRM Multisite. This is too bad but really this seems to be far too complicated and very risky. That would also damage the work of people using different sites. We use only the Domain Group S-group for Site S to be sure we have the right contact in the right site.

---
Tags: groups, acl, multisite, drupal-multi-site, domain
---


# Question
Title: What is the recommended upgrade increments to CiviCRM 5.7 from CiviCRM 5.0?
I've done lots of CiviCRM upgrades over the years in Drupal but I've had CiviCRM complain in the past if I skip too many versions so I'm being a little overcautious maybe.

I have a Drupal 7 / CiviCRM 5.0 site that I'd like to upgrade tomorrow to 5.7 and I wonder if I need to upgrade in increments or whether I can just jump ahead and let the upgrade script upgrade the db all in one go.

What's the best practice for this?

Thanks, Andrew

# Answer
> 9 votes
The 5.x series has a new point release every month, with a focus on stability (generally, large new features go into extensions).

So upgrading 5.0 -\> 5.7 is the equivalent of upgrading 4.7.20 -\> 4.7.27, a minor upgrade and generally considered safe to do at once.

# Answer
> 3 votes
In my experience it varies widely, often do to the amount of custom functionality, and contrib extensions, modules, and plugins that create data in the database, and may not do so exactly as CiviCRM's standard forms do.

I've upgraded at least 75 different websites over the years, with a wide variety of starting points and custom features.

Often we can upgrade large jumps in versions and it works. Sometimes it takes three or four increments. Recently I upgraded a site from 4.6.8, to 5.7 . I had to upgrade first to 4.7.31, then to 5.2, finally to 5.7. I could not get to 5.7 from 4.7.31. Conversely I also upgraded a different site recently from 4.7.13 to 5.7 without incremental steps, smooth as silk.

Generally it is best IMO to upgrade when there are security releases, which two or three per year is common. The exception to my rule is if I specifically need a feature.

I find upgrading with each minor version when it comes out tedious and time consuming... especially if the site has many extensions / modules / plugins, and customs, because it's not worth the risk of a feature breaking unless the new minor release has a feature I actually need.

# Answer
> 2 votes
I too have run into too many issues if I skip some. I just go ahead and do them all and find that I run into a lot less issues.

---
Tags: drupal, upgrade
---


title: how to find .tpl file?

text:
# Question
Title: how to find .tpl file?
I installed civicrm 5.7.2
I am trying to find a perticular tpl file related to new individual contact.When I trying to search it shows me 'no matches'.

I referred a civicrm documentation

# Answer
You can find the tpl file which is used to build the html by viewing page source.

1. Go to **Administer menu \> System Settings \> Debugging and Error Handling**, select **Yes** for *Enable Debugging*.
2. Visit the page/form you want to check which tpl file is invoked.
3. Right click \>\> View Page Source.
4. Ctrl + F to find **tpl**
> 3 votes

---
Tags: civicrm-home, core
---


# Question
Title: How do I get the Name and Address on the Invoice to show up in a Window Envelope?
A client recently asked me the following question: I need to be able to mail (postal mail) invoices to our Members. Our pre-printed size 10 envelopes have a window bottom-left. How can I get the Member's Name and Address on the Invoice to show up in that Window?

# Answer
This requires editing of the Contribution Invoice Receipt - Message Template. End result looks like this:

I'll detail the steps below to get the header part.

The header portion contains two tables: the first table is used to add your logo. The second table has the formatting for the Name and Address section: note that we're putting the Member's Name and Address on the far left and in a slight larger font.

```
   <table width="100%" border = "0" style = "margin-top:20px;margin-right:40px;">
        <tr>
          <td align="right" height="50"><img src = "https://www.yoursite.com/sites/yoursite/files/logo_250x.png"></td>
        </tr>
   </table>

   <table width="100%" border = "0" cellpadding = "2" cellspacing = "1" style = "margin-top:35px;margin-right:20px; font-family: Arial, Verdana, sans-serif;">
        <tr>
          <td width="40%" rowspan="3"><b><font size = "4" align = "center">{ts}INVOICE{/ts}</font></b></td>
          <td width="25%"><b><font size = "1" >{ts}Invoice Date{/ts}</font></b><font size = "2"> </font></td>
          <td width="35%"><font size = "1">{$domain_organization}</font></td>
        </tr>

        <tr>
          <td><font size = "1">{$invoice_date}</font><font size = "2"> </font></td>
          <td><font size = "1">{$domain_street_address}</font></td>
        </tr>

       <tr>
          <td><font size = "1"></font><font size = "2"> </font></td>
          <td><font size = "1">{if $domain_city}{$domain_city|upper}{/if} {if $domain_state }{$domain_state}{/if} {$domain_postal_code}</font></td>
        </tr>

        <tr>
          <td><font size = "2">{$display_name}</font></td>
          <td><b><font size = "1" align = "right">{ts}Invoice Number{/ts}</font></b></td>
          <td><font size = "1">{if $domain_country}{$domain_country|upper}{/if}</font></td>
        </tr>

        <tr>
          <td><font size = "2">{$street_address} {$supplemental_address_1}</font></td>
          <td><font size = "1">{$invoice_number}</font></td>
          <td><font size = "1">{if $domain_email}{$domain_email}{/if}</font></td>
        </tr>

        <tr>
          <td><font size = "2">{$city|upper} {$stateProvinceAbbreviation} {$postal_code}</font></td>
          <td></td>
          <td><font size = "1"> {if $domain_phone}{$domain_phone}{/if}</font> </td>
        </tr>

        <tr>
          <td></td>
          <td><b><font size = "1">{ts}Reference{/ts}</font></b><font size = "2"> </font></td>
          <td></td>
        </tr>

       <tr>
          <td></td>
          <td><font size = "1">{$source}</font><font size = "2"> </font></td>
          <td></td>
        </tr>

    </table>

```
> 4 votes

---
Tags: message-templates, invoice
---


title: CiviCRM view activities permissions

text:
# Question
Title: CiviCRM view activities permissions
I have a role to view contacts in a particular group granted through CiviCRM view ACL permissions (`/civicrm/acl?reset=1`) but even though the role can see all contacts in that group, when trying to view an activity of a contact in that group, user gets an error message "you do not have permissions to access this page".
\- CiviCRM: view all activities is enabled for this role
\- CiviCRM: view all contacts is disabled for this role
\- CiviCRM: edit all contacts is disabled for this role

I have one activity type which i want to exclude users with that role from seeing the same activities of other contacts in another group.

any suggestion for a possible soultion will be much appreciated, I'm on CiviCRM 4.6.35, Drupal 7

If i enable CiviCRM: view all contacts, the role will be able to view all activities of other groups as well.

# Answer
There is an extension ACL for Activity Types that provides ACL for activities based on activity type. This extension allows one to define permission for CRUD operations for each CMS role.
> 0 votes

# Answer
If you give that role access to No Activities, and then build a Drupal View that has the required filters then those users would be able to 'see' the restricted Activities but no others.

There is no reason you can't then deliver this view as a Tab for those folk to use (though i don't have the extension link to hand for that part of the suggestion)

EDIT: I think this one will offer a good starting point: fuzion.co.nz/blogs/view-show-current-users-activities

ps 4.6.35 is not secure
> 0 votes

---
Tags: activities, permissions, acl
---


title: Alert Admins when changes are made?

text:
# Question
Title: Alert Admins when changes are made?
If someone with access to the Civi dashboard makes a change to any contact information, is there a way to send an email alert to the site Administrators?

Civi 5.2 WordPress 4.9

\***ADDITIONAL INFO ADDED 11/30 \****

I am experimenting with CiviRules. It looks promising, but I still haven't found a solution. I am going to spell out more what I am trying to do and hopefully someone can clarify if Civirules can achieve that.

We have about 60 volunteers sorted in a group. Occasionally a member of the staff will make a change to a volunteers contact information. The Coordinator who oversees this group of volunteers wants to receive an email alert anytime a change is made to any contact within that group.

It looks like we might be able to do that with CiviRules, but I am not yet seeing how to apply a rule to a specific group and how to get it to email a specific person when a change is made to that group.
I have the Linked Trigger set to "contact of any type is changed" I am not seeing anything that sounds like it fits in Linked Conditions or Linked Action, such as email this coordinator when a change is made.
I guess I am still not understanding how it works.

# Answer
I am not sure I understand completely what you want to achieve, but if you want to send an email to checks@example.org every time a contact in group Special changes here is what you would have to do:

* install the Email API action (https://civicrm.org/extensions/e-mail-api) which will also add the CiviRule action *Send Email*
* add a new Rule with trigger *Contact of Any Type is Changed*
* add condition *Contact is in Group* and select group Special
* add an action *Send Email* and add email address checks@example.org
> 2 votes

# Answer
That could be a lot of alerts! You could write something using hook\_civicrm\_pre or hook\_civicrm\_post. It might be more practical to create a report for an admin's dashboard than send a mail on every change.
> 0 votes

# Answer
You could possibly use the CiviRules extension (https://civicrm.org/extensions/civirules)( to achieve that? There is also documentation for the extension at https://docs.civicrm.org/civirules/en/latest/.
> 0 votes

# Answer
> Occasionally a member of the staff will make a change to a volunteers contact information.

How about that make that change via a Profile and then you can set the Profile settings to notify someone, ie do this instead of having the changes made directly on the Contact Summary screen. I think that logic would get what you want, but understand it could be hard to get they 'staff' to remember to only change certain records via a Profile
> 0 votes

---
Tags: wordpress, contacts, civirules
---


# Question
Title: Is a Scheduled Reminder possible when something doesn't happen?
A client has asked that an email or SMS reminder be sent if a user ***fails*** to submit a weekly report. The weekly report would be created as an activity - for example, by noon every Friday. I can't quite see how this can be done, but others may have more imagination then me! So, is this possible? Perhaps using a combination of CiviRules and Scheduled Reminders?

# Answer
> 2 votes
How about something like

* create a Group of all possible recipients of the reminder (X)
* create a Smart Group of all those who did the Report (Y)
* create a Smart Group Z = X-Y (use 'Custom Search = Include/Exclude)
* use Z as your 'target' in Scheduled Reminders

Alternatively

* create the Activity for every person who needs to do this
* set the Activity to Scheduled
* ensure that submitting the Report sets the Activity to Completed
* set Reminder to go to all those that are still set as Scheduled

# Answer
> 1 votes
Another idea is not CiviCRM native, but you can use Drupal Rules. Create a Rule Set component that sends the reminder email. Maybe call it reminder. Make it accept either the Drupal UserID or the CiviCRM ID plus the Activity ID as a parameter.

Get all the people you need to a CiviCRM group.

Create an activity and assign it to each person in the group.

Then create a rule that is triggered by the activity being created and scheduled.

The rule schedules the Reminder email to be sent in a week's time

Then create a rule for when the activity is updated and completed.

This rule unschedules any existing reminders the same user and the same activity ID.

# Answer
> 1 votes
Here's one workable solution to having a Scheduled Reminder occur when something doesn't happen - as opposed to when it does. I used CiviRules to create scheduled activities weekly for each member of a group who must do a report - to make it weekly I selected 'Daily trigger for group' and then selected 'Delay action' to 'Every week'. The activity type is 'Weekly Report'. Then I used Scheduled Reminders to remind users to update the weekly report activity and set it to completed. - based on looking for the activity types as 'Scheduled' - 1 hour after they were created by CiviRules. And then another Scheduled Reminder at a later time - checking if the activity was still 'Scheduled' and not 'Completed'. Works a treat - credit to Pete!

---
Tags: drupal, scheduled-reminders, civirules
---


# Question
Title: How can I improve the performance of the change log table?
Retrieving the change log for a contact takes ages for my client - maybe a response of 10 minutes to get just 79 records for one contact. The contact database has about 39K rows, but with about 950k rows in the civicrm\_log table (there are lots of transactions). Logging is switched on, which at the time seemed a very attractive option.

Would adding an index help? I have defragged & optimised the civicrm\_log table, but to no effect.

# Answer
> 11 votes
If logging is on then results will be retrieved from the log\_xxx tables not civicm\_log.

Normally these tables use the archive engine - which is not indexable. We have in some cases selectively converted these to INNODB & added indexes

Archive tables are supposed to be quick to write to and slow to read from. They are also non-transactional - which means that if a rollback happens for a given transaction the archive table record will not be rolled back (on rare occasions this has helped us with forensics)

EDIT: also take a look at this extension I wrote https://github.com/eileenmcnaughton/nz.co.fuzion.innodbtriggers which converts log tables to innodb automatically and this blog post for more details: https://civicrm.org/blog/eileen/who-did-what-when

# Answer
> 3 votes
For people googling, I significantly increased the speed of the Change Log by following Eileen's advice in her answer: convert some tables (activity, activity\_contact, contact, group, group\_contact) from ARCHIVE to INNODB, and adding indexes.

The Change Log still takes ~20 seconds to load, but that's much better than the minutes it used to. We've taken a hit on disk space, and I suppose write speed (though I can't tell the difference), but definitely worth it!

# Answer
> 2 votes
The log tables as originally implemented (I have checked for a few years if this is the case) also contain a large number of superfluous records due to writes that don't actually change the data. Improving the triggers to check for a difference between old and new values before the write to log would improve things for everyone.

# Answer
> 2 votes
Take a look at the INNODB logging extension. It converts the log table format from ARCHIVE to INNODB, adding indexes and speeding up as a result.

# Answer
> 1 votes
Pretty sure an index would help indeed, the question is which one?

Can you log slow queries on your database and see which queries are taking a lot of time, see where it can be added?

finetune how many seconds before a query is slow (any query that takes more than 1 or 2 sec is slow is what I use)

http://dev.mysql.com/doc/refman/5.7/en/slow-query-log.html

# Answer
> 1 votes
I discussed this with Bjorn Endres, and his idea is to turn logging off, drop the log tables, and then turn logging back on. This is, I think, a good answer. The reason our log tables are so big is because we have transferred data from a legacy system. We don't really need 99% of the data in these logs so this is what we intend to do. Thanks, Bjorn!

---
Tags: 4.6, performance, logging, db-logging, mysql-archive-format
---


title: Extend templates through the hook file

text:
# Question
Title: Extend templates through the hook file
I have configured the "Custom" folders for templates and PHP following https://docs.civicrm.org/dev/en/latest/framework/templates/extending-smarty/

I created this hook file (and I'm sure it's executed)

```
function joomla_civicrm_config(&$config) {
  $smarty = CRM_Core_Smarty::singleton();
  array_push($smarty->plugins_dir, __DIR__ . '/plugin/');
}

```

in the "plugin" subfolder (relative to the hook file), I created the function.attachment.php with the code

```
function smarty_function_attachments(array $params, Smarty_Internal_Template $template) {
  $template->smarty->loadPlugin('...');
}

```

but this last function is not performed. Where am I wrong?

Thank you

# Answer
I see the name of the function is `attachments` and the file name is `attachment`. Maybe, you just need to remove an extra "s" from the function name?

```
function smarty_function_attachment(array $params, Smarty_Internal_Template $template) {
  .
  .
}

```
> 1 votes

---
Tags: smarty, custom-templates
---