# Question
Title: After installation Civi menu and dashbord do not show (SOLVED)
after a successful installation of CiviCRM 4.7.19 on WordPress 4.7.4 – the installer said everything was fine –, the menu and dashboard of CiviCRM does not show.

I know, this issue has been addressed elsewhere, but the solutions proposed there didn't work for me.

For instance, in the following case: Civi dashboard and menus won't display after install the solution seemed to be to replace the CiviCRM Resource URL which was set to default. However, the solution does not say, how to find and access this Resource URLs settings page where this default would have to be changed.

In another solution Word Press Install Missing civicrm.settings.php; dashboard unavailable; no menus it was suggested to install a certain plugin https://wordpress.org/plugins/civicrm-admin-utilities/ , which unfortunately also did not help me.

I've also looked into similar cases on Drupal, like this one: Civicrm menu is hidden There someone suggested to rebuild the menu via adding /civicrm/menu/rebuild to my page, but it only gave me an error saying I'm not permitted to access that page.

I'd be glad to hear some of your ideas on this issue.

Thanks and best regards! Jannis

EDIT: Posted the solution below.

# Answer
Thanks for all your good ideas. Finally I've solved it by going through the first case I've listed above: Civi dashboard and menus won't display after install.

Though I could neither access the menu nor find the resource URL in my database, I found a link to the administer page in the case, which is `wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin&reset=1` There I could change the default to the actual CiviCRM Resource URL.
> 3 votes

# Answer
I just came across this page, with a similar issue.

In my case it was because I was configuring a Staging Server clone of the live site. I had not yet added an exemption for the new site to my NoScript browser extension, so JavaScript was not running. Oops. Maybe this will help someone else.
> 1 votes

---
Tags: wordpress, installation, dashboard, menu
---


# Question
Title: How to use full unicode on custom fields
There's an API call `System.utf8conversion` which will change all your tables to MySQL/MariaDB's utf8mb4 format, i.e. full unicode with emoji support, rather than the incomplete utf8 implementation of old.

I ran this and it worked fine but then found that when I add a custom fieldset, that table is set to the old UTF8 charset.

# Answer
> 4 votes
Incomplete UTF8 support is hard coded into the core code before 5.33 (*thanks @michaelmcandrew!*).

The solution seems to be to re-run the `System.utf8conversion` routine

* Pre 5.33: do this after any time you create a field/fieldset (including anytime you install an extension that creates a custom field/fielset)
* 5.33+ do this once, then the only time it should be needed again is if an extension hard-codes the old UTF8 in place.

Note that you can use the uh-oh extension to help discover whether your db uses the old UTF8 stuff.

---
Tags: custom-fields
---


# Question
Title: Contribution total amount being doubled when Tax Rate is set to 0 on manual membership renewal
We're running on Drupal 7 and the latest ESR 5.27.5 (was able to replicate on dmaster).

On manual membership renewal with the member dues financial type which has a VAT/GST account attached to it that has 0% tax rate, sets it to pending, the contribution total amount displayed is double the actual contribution total.

I thought this was only on the ESR version but I was able to replicate this on https://dmaster.demo.civicrm.org

Steps to replicate:

1. Add a VAT financial account with tax rate 0
2. Add the financial account to the member dues financial type
3. Go to any contact with an active membership.
4. Renew the membership manually and set the status to pending and save. Check the contribution total amount.

**Instead of setting it to pending, if the payment is set to completed, the total amount is correct but the subtotal seen on the invoice is incorrect.**

This only happens when tax rate is set to 0.

If the tax rate is even set to 0.0000001, this does not occur. Thought I would bring this up because I'm assuming it affects a few version.

This is still visible on dmaster if someone wants to check.

# Answer
> 1 votes
Try upgrading civi to 5.28.4 as it should be fixed in this version

---
Tags: drupal, civicontribute, taxes
---


title: How to try out new 'Search Builder'?

text:
# Question
Title: How to try out new 'Search Builder'?
I understand from other posts that the new Search Builder is included in 5.29 but is hidden. I'd like to give it a try - how can I access it?

# Answer
> 6 votes
Note if you install from a tar file the extension is not available until 5.30. Git/composer/buildkit installs have it in 5.29.

Also the styling on the search page is messy until 5.31, and before then has some other issues.

**UPDATE**: As of 2020-10-06, it's now visible in the UI as an installable extension called "Search Kit" that comes included with 5.31+. You just install it like any other extension. For earlier than 5.31 see below.

---

# Using user interface

1. In civi go to the menu for support - developer - api3 explorer.
2. Choose Extension with action Install.
3. For parameter pick Extension Key, and for the value put org.civicrm.search.
4. At the bottom click Execute.
5. Then the Search menu will have a new option at the bottom.

# Using command line

1. `cv api Extension.install keys="org.civicrm.search"`

---
Tags: search-builder
---


title: Is there a token for base url?

text:
# Question
Title: Is there a token for base url?
We are often caught by having links in Message Templates that work on live, but then incorrectly take us to the live site when testing on dev - which can result in confusion or worse, errors or incorrect conclusions.

Anyone know if there is such a token but it just isn't visible via the token selector?

# Answer
> 5 votes
No, there is no token for base URL is available in civicrm. If you want to use base URL in templates, you can try this:

```
 // Declare $config;
 $config = & CRM_Core_Config::singleton();

 $baseUrl = $config->userFrameworkBaseURL;

```

This will gives you base URL and use variable "$baseUrl" in your template.

Another way is, you can create your custom token for base URL.Refer following link: http://wiki.civicrm.org/confluence/display/CRMDOC/Customized+%28and+Custom%29+Tokens

# Answer
> 2 votes
There is a JIRA ticket that seems related here but no evidence of an actual resolution to it.

# Answer
> 2 votes
I had the same requirement (moving email templates between test and production). So I created a small extension that adds a Site URL token. You can find it here https://lab.civicrm.org/kainuk/siteurl

---
Tags: tokens
---


title: When are scheduled reminders sent?

text:
# Question
Title: When are scheduled reminders sent?
We are in the process of setting up some renewal reminders for lapsed members. The reminder is set to be sent 7 days after the membership end date.

What I wanted to check is whether this reminder will be sent to members whose end date is *exactly* 7 days before or if it will be sent to members whose end date is 7 days or more? i.e. will it be sent to members that expired 8 days ago, 14 days ago, 2 years ago etc?

I presume that it is an exact match. Could someone confirm this (and ideally point to where this is in the code)?

What I don't want to do is send the reminder to every former member including those that expired years ago.

# Answer
Schedule reminders configured for all the available entities except for participant will send reminder on exact same day match in your case it would be on 7th day after expiry date.

For events participant its different, in current version of civi if you have configured send reminder for event start date after 7 days than it will send reminder for all the participant whose event start date is past 7 days
> 2 votes

---
Tags: civimember, scheduled-reminders
---


# Question
Title: CiviCRM Initalization Error: DB Error: extension not found
I've got CiviCRM installed within a WordPress context, and both are updated. The problem is that, with the last update that occurred, I can no longer get to CiviCRM. Instead, I get the following displayed on a blank page without any styling:

```
Initialization Error

Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => simpleHandler
        )

    [code] => -25
    [message] => DB Error: extension not found
    [mode] => 16
    [debug_info] =>  [DB Error: extension not found]
    [type] => DB_Error
    [user_info] =>  [DB Error: extension not found]
    [to_string] => [db_error: message="DB Error: extension not found" code=-25 mode=callback callback=CRM_Core_Error::simpleHandler prefix="" info=" [DB Error: extension not found]"]
)

```

Does anyone have any idea how I can fix this? It says an extension is not found, but there is no mention of what the extension is or why it's missing as the result of an update.

# Answer
This turned out to be the issue with PEAR trying to load DB (mysql) extension. PHP mysql extension is removed from PHP7.

For those who landed here with same errors, when trying to execute commands with `civix` or `drush` which uses command-line php (php-cli), if your OS has installed both PHP5 and PHP7, the default `php` command available in `/usr/bin/php` refers to PHP7 while PHP5 executable will be available as `/usr/bin/php5`

One needs to update `/usr/bin/php` to `/usr/bin/php7` and direct `/usr/bin/php5` towards `/usr/bin/php`. Maybe using `update-alternatives` would be best suited.
> 2 votes

# Answer
I was facing the same error. I solved it by changing `mysql:` to `mysqli:` in `civicrm.settings.php` file. Reference - https://issues.civicrm.org/jira/browse/CRM-17874

Thanks.
> 1 votes

---
Tags: wordpress, upgrade, database, error
---


# Question
Title: CiviCRM Frontend or Public-Facing Page 404 Not Found
It seems that all of CiviCRM frontend/public-facing pages are not working for me, they either redirect to the homepage (Petition), or throws a 404 not found (Other pages like Profile Create Mode & Mailing).

I have:

1. Created a blank base page named "CMS" and use the base page in **Administer \> System Settings \> CMS Database Integration**.
2. Set all permission for public/guest viewing in **Users and Permissions \> Permissions (Access Control) \> WordPress Access Control**

If I insert the Profile forms manually on their own page, they work fine and I can view/submit the form.

CiviCRM Installation Details:

* WordPress 5.5.1
* CiviCRM 5.24.6

# Answer
Since you are on wordpress 5.24 you need to have civicrm 5.26 or more. Would recommend to upgrade your CiviCRM to 5.28.4
> 1 votes

---
Tags: wordpress, base-page
---


title: Create array in Smarty template

text:
# Question
Title: Create array in Smarty template
I want to modify the Smarty template sites/all/modules/civicrm/templates/CRM/Case/Audit/Report.tpl. I want to complement an existing foreach expression with comparing the incoming variable $group.title to an array of titles, and execute the following code only if the current $group.title is found in that array.

```

{assign var=visible-fields value=['value1, value2']}
<div> Visible fields var: {$visible-fields} </div>

{if $group.title|in_array:$visible-fields}
  <h2>{$group.title}</h2>
  <table class ="report-layout">
  {foreach from=$group.values item=row}
      <tr>
      <th class="label">{$row.label}</td>
      <td class="crm-case-report-custom-field">{$row.value}</td>
      </tr>
  {/foreach}
  </table>
{/if}

```

Now, I'm getting stuck on a rather simple task: The array `visible-fields` is not created. I have found some forum threads from the 2000s suggesting some expressions. I have tried the following, none of which seems to work:

* `{assign var=visible-fields value=['value1, value2']}`
* `{assign var=visible-fields value=['value1', 'value2']}`
* `{assign var='visible-fields' value=['value1, value2']}`
* and the same with "" instead of ''
* `{assign var="visible-fields" value=","|explode:['value1, value2']}`

Printing the variable with `<div> Visible fields var: {$visible-fields} </div>` results in a 0.

I also tried solving the problem with a `{php}...{/php}` block, but then the web app throws an error. Maybe I have to enable the support for these inline php blocks somewhere, but before trying that, I want to try solving it with the Smarty expression, because creating an array shouldn't be so difficult, right?

Can somebody tell me how to do it, or post a link?

# Answer
This method works for me:

```
{assign var=visible_fields value=','|explode:'value1,value2'}
<div>Visible fields var:
  {foreach from=$visible_fields item=foo}
    <div>Element is {$foo}</div>
  {/foreach}
</div>

```
> 1 votes

---
Tags: civicase, templates, smarty
---


# Question
Title: How do you approach "things that you would use Drupal views for" in WordPress?
Coming from a Drupal 7 background but wanting to do more work with WordPress, I am looking for ideas on how people approach *"the things that you would normally use Drupal views for"*.

For any WordPressers that are unfamiliar with views, I'll try and explain it in once sentence: it is a UI that allows you to run queries on your DB and format these nicely on the screen.

Tools with a GUI are nice, though not necessary - I'd be happy coding stuff. Just thinking that it would be great if there was a framework / set of libraries that I could use, to avoid too much wheel reinvention.

To give a bit of context: I'm creating the data entry part of a monitoring and evaluation system. We'll most likely use Caldera forms for the actual data entry but I want to create a customized dashboard that front end users of the site (without any other access to CiviCRM) that will give an overview to users of what they need to do and point them towards the forms that they need to fill in, etc. Happy to provide more details if that would be helpful.

Tips and tricks and examples are very welcome.

# Answer
Interesting, we (as in CiviCooP) are on the same quest. We will do a work-together on 9 November and I expect one of the projects coming out of that to develop a View-type of Wordpress plugin. Want to join us if we are going to do this in a sprint?
> 1 votes

# Answer
See this question first: What is the recommended Wordpress equivalent for drupal-views for some ideas and then consider the Views plugin for WordPress, what they call "the Query Builder for WordPress."

Then of course there is the Query Wrangler plugin.
> 1 votes

# Answer
Building on Pete's answer - in 2020 the solution is the Agileware fork of Content Views CiviCRM plus Data Processor. This blog post has relevant download links.
> 1 votes

# Answer
Take a look at CiviCRM ACF Integration which will sync Civi data into WP. Then you can handle displaying the data using various WP methods. It's in early stages but there's lots of room to grow... Let WP display content and Civi manage contacts.
> 1 votes

# Answer
A wordpress plugin "Query Wrangler" provides some basic functionality similar to that of drupal views module.
> 0 votes

# Answer
For simple table views, I find that CiviCRM custom searches usually do what we need :

1. display a table of results with the columns and data you want
2. allow to add some filters

Advantages :

* it's CMS agnostic
* you can do the filters you need (or no filters if you don't want any)
* you have full control on the generated query (functions like select(), from(), where() or sql() if you want to have a very specific query)
* you get all the usual searches actions for Contacts (add to group, create a smart group, export, send an email...)

Drawbacks :

* you need programming skills (but it's no so hard)
* for other than table display, you need to create your own .tpl and you might have to do quite some work

I can't find any recent documentation but you can find this page : https://wiki.civicrm.org/confluence/display/CRMDOC42/Create+a+Custom-Search+Extension
> 0 votes

# Answer
Work is happening to make https://github.com/mecachisenros/content-views-civicrm useful

Referenced here https://chat.civicrm.org/civicrm/pl/g9913yqt1tnmdesc85g6m34xph
> 0 votes

---
Tags: wordpress, drupal-views, caldera-forms
---


title: Wordpress Installation Bug?

text:
# Question
Title: Wordpress Installation Bug?
Anyone has experience installing CiviCRM in Wordpress? I tried to follow the installation guide but I come with this problem, Google doesn't offer much help. It comes with an error in the database name "The database name provided is not valid. Please use only 0-9, a-z, A-Z, _ and - as characters in the name." Any help or direction to get help will be appreciated.

# Answer
For whatever reason, Civi requires it to have at least one letter (lower case or upper doesn't matter).

See https://github.com/civicrm/civicrm-core/blob/5.29.1/CRM/Core/DAO.php#L2992
> 1 votes

---
Tags: wordpress, installation
---


title: CiviCRM on WordPress wont Install Issue

text:
# Question
Title: CiviCRM on WordPress wont Install Issue
I'm brand new to CiviCRM and have been asked in stall in a test site and review how it works.

I have the latest WP 5.5 installed. I've uploaded CiviCRM via ftp to the plug ins folder. I went to the installer and I got the error in the screen shot below. Had a look at docs and I updated PHP to 7.2 and same thing happened.

Can anyone tell me if this is common and what fix may be required or is there a doc you could direct me to?

Many thanks, J

THE ERROR: In CiviCRM Database Details

IN RED: Can I create temporary tables in the database? = Could not create a temp table. Can I create lock tables in the database? = Could not create a table in the database. Can I create triggers in the database? = Could not create a database trigger.

IN YELLOW Is the utf8mb4 charac=hter set supported = It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb\_large\_prefix=true innodb\_file\_format=barracuda innodb\_file\_per\_table=true

# Answer
> 1 votes
Seems like your Civi MySQL database user does not have sufficient privileges attached to it to allow it to install Civi.

This link here should provide you with the information that you need. It is quite old but should get the job done - https://forum.civicrm.org/index.php%3Ftopic=23489.0.html

# Answer
> 0 votes
Check your privileges on the database, John. I suspect this may be a MySQL issue.

W

---
Tags: database, datatables
---


title: WorldPay extension

text:
# Question
Title: WorldPay extension
Does anyone know of a working WorldPay extension? I know there was an alpha version developed by MillerTech in 2015 but unsurprisingly this doesn't work. I would be surprised if a company has not paid for an extension to be developed for themselves. We can contribute towards this but cannot afford to have this developed ourselves.

# Answer
> 0 votes
We have one that we've been using for a few clients, we could share it if you needed one?

---
Tags: payment-processor
---


# Question
Title: Cannot create or edit emails or templates in Mosaico
Just migrated a WordPress site to a new server. When we try to create, edit or adjust a template that uses Mosaico we cannot get the following (this is from the edit mosaico templates page and the console shows 404 errors.

We have done the following:

* Checked both directories & resource urls settings. We have also put hte full paths in these settings
* Cleared Cache
* Reinstalled Mosaico & Flexmailer
* Upgraded CiviCRM from 5.28.2 to 5.28.4

It seems Mosaico cannot load the requested

# Answer
It turns out the issue was being caused by the resource url for the extensions directory. The path was set correctly but the resource url had a typo. The extension directory was not the standard /ext. Once the resource url was corrected and the cache cleared all works fine.
> 1 votes

---
Tags: mosaico
---


# Question
Title: Why is CiviCRM mistranslating my string?
My site is translating Yes to Si for French (fr\_FR). I've confirmed that:

1. I don't have any word replacments for Yes.
2. Most everything else is translated correctly.
3. I've got an up-to-date civicrm.po file for fr\_FR and it contains the correct translation of "Oui".

I've even installed the brilliant de.systopia.l10nmo and org.civicrm.l10nx extensions and uploaded an override .mo file.

WTF?

# Answer
In the file /CRM/Core/BAO/WordReplacement.php you've got this delightful stanza:

```
// So. Weird. Some bizarre/probably-broken multi-lingual thing where
// data isn't really stored in civicrm_word_replacements. Probably
// shouldn't exist.
$stringOverride = self::_getLocaleCustomStrings($id);
$stringOverride[$config->lcMessages] = $overrides;

```

And digging in, you'll see it does this:

```
$domain = CRM_Core_DAO::executeQuery('SELECT locale_custom_strings FROM civicrm_domain WHERE id = %1', [
  1 => [$domainId, 'Integer'],
]);

```

In other words, it's pulling word replacement information from a field in the civicrm\_domain file which is no longer accessible or used in the UI.

I looked in there and sure enough, I had an old collection of translations. By setting the field to empty, it solved the problem.
> 1 votes

---
Tags: i18n
---


# Question
Title: Finding contacts without relationships (API)
How can I find contacts using the APIv4 that don't have any relationships of a specific type?

I want the first n contacts ordered by a date field meeting various conditions excluding those with a relationship of type X.

There are various ways it could be done with multiple calls or php looping but it would be nice to be able to do it in a single call.

In SQL one option using a subquery is:

```
SELECT * FROM Contacts
WHERE <various things>
AND contact_id NOT IN (SELECT contact_id_a FROM Relationships WHERE <conditions>)
ORDER BY <something>
LIMIT <n>

```

Can APIv4 produce something like that?

# Answer
> 4 votes
Yes you can! I fiddled with the APIv4 Explorer a bit and came up with this:

The trick is to join onto `RelationshipCache` with the relationship type(s) you are wanting to exclude (note that the double quotes around `'"Parent of"'` are needed because you are passing a string literal not the name of a field or other SQL expression). And then in the WHERE clause specify that you want the relationship\_cache.id to be NULL.

The `GroupBy` is necessary because your join can potentially produce duplicate results if the contact has more than one relationship, although technically that's impossible with this query so, meh, you could try leaving it off.

---
Tags: api, apiv4
---


# Question
Title: Why am I getting a warning about hook_civicrm when Civi's cron runs?
On Drupal 7.73 with CiviCRM 5.29.1. Every time the CiviCRM cron runs, I get the following warnings in the Drupal watchdog log. Each is a separate entry.

hook\_civicrm\_alter\_drupal\_entities should be updated to pass an array of parameter names to CRM\_Utils\_Hook::invoke(). Array ( \[civi.tag\] =\> deprecated )

hook\_civicrm\_entity\_supported\_info should be updated to pass an array of parameter names to CRM\_Utils\_Hook::invoke(). Array ( \[civi.tag\] =\> deprecated )

Any suggestions for how to fix this would be most welcome :-)

Thanks.

# Answer
I'm assuming you have the civicrm\_entity module installed. There's an open pull request for this at https://github.com/eileenmcnaughton/civicrm\_entity/pull/238

If you're able to test out that patch and comment there on that PR it might get merged faster.
> 4 votes

---
Tags: drupal, cron, hooks
---


# Question
Title: "My Registered Events" listing (with cancellation option) for user dashboard page
I've searched and researched and come up empty - is it possible to present a dashboard (summary) view of the events that a person has registered for, along with the ability to easily cancel from any of the listed events? It seems like a very useful thing to have but I'm coming up empty when trying to find any mention of doing so with CiviCRM.

# Answer
The feature you're referring to is called the "Contact Dashboard", and it's accessible from https://yoursite.org/civicrm/user in Drupal and Backdrop, not sure about WordPress.

You can add/remove sections from it at **Administer menu » Customize Data and Screens » Display Preferences**.

It doesn't allow self-service cancellations, but I wrote the extension "Event Self Service from User Dashboard "to deal with this specific scenario.
> 4 votes

---
Tags: civievent, user-dashboard
---


title: How to save a search criteria?

text:
# Question
Title: How to save a search criteria?
is there a way to save the search criteria from a 'search builder' or 'advanced search' for future use without making it a smart group? TIA

# Answer
I don't think so, but there is some support for bookmarking a url for certain types of searches:

https://docs.civicrm.org/user/en/latest/the-user-interface/searching-url-support/
> 1 votes

# Answer
Might be worth using the data processor extension? I do for more complex advanced searches that I want to save for easy access.
> 1 votes

---
Tags: contacts, groups, search
---


# Question
Title: how can I filter the list for address > "country" field in "new individual"
I want to filter the option list of the "country" field on the address tab.. I found out that the country field is getting the list of country field in "civicrm\_country" table and I want to add a new column "is\_active" on the table for the filtering but I can't find the function that generates the list.. does someone know where I can find the function generating the option list so I can add the filter? thanks a lot

# Answer
> 1 votes
Welcome to CiviCRM SE, Could you please tell why you want to add 'is\_active' field to country table? Can't you just disable the countries from appearing in drop down(or include only countries that you need in your system) from CiviCRM \>\> Administer \>\> Localization \>\> Languages, Currency, Locations?

---
Tags: addresses, individual, fieldoptions
---


# Question
Title: Dead links on events, donations, pretty much anything I create
I'm in the middle of an install and stuck on a couple issues.

I've been all over this StackExchange yet I can't seem to make basic CivicCRM links work in a couple of sections in the site I'm trying to deploy.

* CiviCRM 5.27.0 running on Wordpress 5.4.2 on top of Ubuntu
* Yes, my WP permalinks is set to "post name"
* yes, I have an .htaccess and it looks like this:

```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

```
* yes, Apache is set up to obey that .htaccess for this site
* yes, my Administer -\> System Settings -\> CMS Database Integration is set, and it's set to https://crm.\[siteiamdeploying\].org/civicrm/
* yes https://crm.\[siteiamdeploying\].org/civicrm/ is a page that exists and loads

... yet when I do things like:

a) Create an event, flesh out its details and see links like TEST: https://crm.\[siteiamdeploying\].org/event/register/?reset=1&action=preview&id=98 LIVE: https://crm.\[siteiamdeploying\].org/civicrm/event/register/?reset=1&id=98

Or, for example, set up a DONATE page and then attempt to load that page by doing

Civicrm-\> manage contribution pages -\> set up a contribution page -\>

... then use that pages "links -\> Live page" or "links -\> Test page" links to try and load those pages, i.e.

https://crm.\[siteiamdeploying\].org/civicrm/contribute/transact/?reset=1&id=4

... all I get on those links is the default WordPress "not found" page, i.e.

"Oops! That page can’t be found. It looks like nothing was found at this location. Maybe try a search?"

And I can see these 404'ing/ erroring out in the Apache access logs like this

67.160.XX.XX - - \[06/Oct/2020:02:15:54 +0000\] "GET /civicrm/contribute/transact/?reset=1&id=4 HTTP/1.1" 404 60939 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"

Can somebody point me in the right direction and/or towards sensible debug logs or processes before I start throwing heavy things at my monitor?

# Answer
> 1 votes
Do you have CMS integration set in your system? You need to have default page or post in WordPress and have it set in CMS integration

---
Tags: wordpress, civievent, civicontribute
---


# Question
Title: CiviCRM upgrade from 5.12 to 5.29 - failure
Tried to upgrade CiviCRM on Drupal 7 website. Drupal core 7.73. Using PHP 7.1. Upgrade process started well but received this message: You must reload the database with the backup and try the upgrade process again. I do have a good backup of database. What should I do? How do you reload the database?

# Answer
> 2 votes
Welcome to SE! There's lots of useful advice from Luke in his answer but I'd start by looking at the CiviCRM log file.

That error message is a bit misleading. It's not random luck as to whether an upgrade succeeds so restoring to the previous state and just trying the same upgrade code is very unlikely to produce a better result. The upgrade probably failed because of a mismatch between what the code was expecting to find in your system, and what it actually found. Until you track down and correct that problem reloading and repeating won't help.

You can often fix the problem and continue the upgrade without reloading a backup.

If you look at the log file you should see the various upgrade steps logged there. What was the last successful upgrade step? What messages do you get after that?

## Update

The log file shows: `Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs`

Updated table to `row_format=dynamic` and then reran the upgrade.

# Answer
> 1 votes
You'll need to track down what caused your error first however. I'd take a copy of your database, potentially a backup of your "broken" database depending on whether this is of any use to you.

The easiest way (assuming you are runnign on dev) is to drop the existing database, recreate it and reload your backup. The exact details for this will depend on how you are interfacing with your mysql/mariadb server - either via a command line (using mysql, or potentially using phpmyadmin or similar) or you might have a different GUI based way. Check the relevant documentation for the tool you are using. This process should be the same as you might restore you live site from backup.

Some things to think about.

You probably shouldn't have any problems if you are reloading the same database but you might want to think about stripping out triggers and views due to them including a "definer" which can cause problems. Assuming you are using the command line the following perl will do this:

```
perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' /path/to/mysqldump.sql

```

For more about that perl and triggers check this question

You will probably want to identify how and why your upgrade failed. Your civicrm\_log table will show you which upgrades ran giving you an idea of where you got up to.

If you have the upgrade window open you can check the console - sometimes error messages will show there.

Then you could try your drupal watchdog log (if enabled).

Otherwise you want to dig into your Civicrm Log - This can usually be found under sites/default/files/civicrm/ConfigAndLog although this can be customised so if you don't see it there check your civicrm.files directory. (Admin -\> System Settings-\> Directories)

If you have a large database and are loading it via the command line you might want to use a utility like pv to track how far through the import you have gotten.

Otherwise you might want to run this upgrade in a staged process - get yourself up to the last upgrade that succeeded by downloading that version first - you can swap out the version in the download link - then run another backup so you won't have as far to upgrade the next time.

# Answer
> 0 votes
There were two discussions about problems 5.29 upgrade recently. Maybe some information in those threads may also help you...

Update to 5.29.0 get frozen

Upgrade db failed for 5:29

---
Tags: drupal, upgrade
---


# Question
Title: Search for people who have NOT registered for an event using a custom search or data processor
I need to search for all users who have not registered for an event. Five years ago, I asked the question, and the answer was to create a group of users who did register and then do an include/exclude search.

The thing is that I need to do this on a regular basis, for many events. Creating a group for every event became too cumbersome.

I am trying to figure out how I can do this search, perhaps using the data processor extension. Where I am stuck is figuring out how to express my intention: "all users who have not registered".

* I tried using a search on Participants. But if someone has not registered, they are not a participant. So using a search like "all participants for event X where status is not Registered" only shows me people who did register but whose status is now Attended or Canceled for example. It does not show me people who have not registered.
* The data processor extension allows you to join data, but I don't see how it lets you do the opposite of a join. Essentially to say "select all users" plus "exclude (reverse of join) any person who is a Participant for this event".

I believe this is where I am thinking about the problem wrong. SQL doesn't have such an exclusion call, instead you are supposed to re-think the question so that it becomes a query where join is possible.

So can anyone help me re-think this so that using "join" function of data processor is possible?

# Answer
```
SELECT cc.id, cp.id
FROM civicrm_contact cc
LEFT JOIN civicrm_participant cp ON cc.id = cp.contact_id AND cp.event_id = 1 WHERE cp.id IS NULL;

```

You can confirm that this works by running this straightforward query to see the contacts who ARE registered for an event:

```
SELECT cc.id, cp.id
FROM civicrm_contact cc
LEFT JOIN civicrm_participant cp ON cc.id = cp.contact_id
WHERE cp.event_id = 1;

```

Then confirm that this query is functionally the same:

```
SELECT cc.id, cp.id
FROM civicrm_contact cc
LEFT JOIN civicrm_participant cp ON cc.id = cp.contact_id AND cp.event_id = 1 WHERE cp.id IS NOT NULL;

```

The first query is the same as the third, except uses `IS NULL` instead of `IS NOT NULL`.

This search should be possible with the forthcoming Search Kit. I tried a pre-release version but there was an error joining contacts to participants. However, I was able to create the equivalent with contributions - "All contacts without a member dues payment". The screenshot below shows how you'll be able to do this with Search Kit very soon:
> 3 votes

# Answer
Not quite what you asked, but Search Kit is based on APIv4 and you can also do it directly with APIv4:

```
$contacts = \Civi\Api4\Contact::get()
  ->addSelect('id')
  ->setJoin([
    ['Participant AS participant', FALSE, NULL,
    ['participant.contact_id', '=', 'id'], ['participant.event_id', '=', '1']]
  ])
  ->setGroupBy(['id'])
  ->addWhere('participant.id', 'IS NULL')
  ->execute();

```

(see also https://civicrm.stackexchange.com/a/37837/225)
> 2 votes

---
Tags: custom-search
---


title: Can I pass a GROUP BY to an API call?

text:
# Question
Title: Can I pass a GROUP BY to an API call?
I'm trying to write an API call returning all contacts that are at one end of one or more active relationships of a certain type, and their names. I note that you can specify limit, offset (LIMIT) and sort (ORDER BY) options. Something similar for GROUP BY, so I don't need to do this in PHP separately after the API call, would be useful. Does it exist?

Like this, for example:

```
$ao_result = civicrm_api('Relationship', 'get', array(
  'version'    => 3,
  'sequential' => 1,
  'relationship_type_id' => 19,
  'is_active'  => TRUE,
  'options'    => array(
    'group_by' => 'contact_id_b',
  ),
  'api.Contact.getvalue' => array(
    'id'     => '$value.contact_id_b',
    'return' => 'display_name',
  ),
));

```

# Answer
> 3 votes
I think this makes sense as an addition - but note that there are 3 types of get api

1) api layer api - e.g anything that uses basic\_get 2) query object api (contact, contribute etc) 3) random assorted api

# 1 is easy & in one place - 2 & 3 are ... not

BUT #1 changes substantially in 4.7 compared to 4.6 so you would need to fix at minimum in 4.7 & add unit tests and ALSO in 4.6 if you want it to work there too.

(We are open to backporting the 4.7 internals en masse to 4.6 with an self-deprecating opt-in -eg. $params\['options'\]\['4.7plusmode'\] = TRUE; \- the 4.7 code also supports custom field filters (e.g on address) and lays the groundwork for more nuanced acls since it permits joins in simple api which is a blocker in 4.6)

# Answer
> 3 votes
Years later - but GroupBy on multiple fields is now a feature of APIv4. Check out the API Explorer for details.

---
Tags: api, database
---


title: Lost database on civicrm

text:
# Question
Title: Lost database on civicrm
I have been working on my membership database on civicrm for the last 4 years and since March I have not been able to access it. I normally type this on google https://hlpacivicrm.esptest.co.uk/cms/wp-admin and I get a prompt to put username and password but I get an unrecognised message at the moment.

# Answer
Seems to be getting certificate errors that lead back to https://espprojects.co.uk

Have you tried contacting your provider who runs this as it looks like it could have been set up as a test site and contract didn't renew in April maybe?

Bari
> 2 votes

---
Tags: database
---


# Question
Title: Why are my CiviCRM queries rewritten to short links that do not work?
I'm running a Wordpress 5.5.1 site with a custom theme that was working fine until a few months ago. With no changes to the site other than plug-in and Wordpress updates, the CiviCRM-generated pages no longer work in Live or test modes, and my site links are briefly displayed before being rewritten to short links that result in a blank template. CiviCRM is version 5.14.0.

Here's an example from the live site:https://cantusnovus.org/support-us/

On this page is an Orange button that links to: https://cantusnovus.org/civicrm/contribute/transact/?reset=1&id=4

When that is clicked, the link is rewritten as: https://cantusnovus.org/civicrm/?reset=1&id=4

To my knowledge, nothing has changed in the hosting environment or Wordpress templates or CiviCRM configuration. Here's what I've tried:

* I removed a redirection plugin I was using (no effect)
* I disabled/removed all plugins not directly needed by CiviCRM just to look for interference (no effect)
* I switched themes to test if something in my custom theme was interfering with the display (no effect)
* I checked (and simplified) .htaccess file to just standard Wordpress setup (no effect)

While CiviCRM works from the backend and I can access/edit forms, I cannot Preview them. I also can't see (preview) previous mailings, etc. I simply can't display anything in live/preview mode.

Any ideas would be much appreciated!

# Answer
> 3 votes
You'll need to upgrade CiviCRM. WP 5.5 made changes to how URL paths are handled which required changes in CiviCRM. I believe those changes were introduced in 5.26. So you will need to upgrade to at least that version to be compatible with WordPress 5.5+.

There was a blog post a while back with more details: https://civicrm.org/blog/kcristiano/civicrm-526-and-wordpress-important-notice

---
Tags: wordpress, forms, display
---


# Question
Title: How to create a recent new contacts report?
I'm trying to create a report of recent new contacts, ideally to make it available to our team as a dashboard widget.

I've managed to get a report with the results I want using the `Contact Logging Report (Summary)` template, but the columns in that (Action, Log Type, Altered By) will be fairly meaningless to the team, so I want the same results displayed with useful information each contact: things like Job Title, City, e-mail, phone, etc.

I've found an old answer that suggests the ability to add columns to templates doesn't exist in CiviReport. Is this still true? And if so, are there any work arounds or extensions that can achieve the same result? I've checked the Extended Reports extension, and even in there I can't find any templates that include both the contact fields and the logging information needed to get a list of recently added contacts.

I'm flexible as to how recent a list I get, as long as it can be sorted with most recent first. And I'm flexible as to exactly which columns I end up with, as long as they're ones that are meaningful to my users.

# Answer
I am not sure if there are any extension that you do your job using reports but you certainly achieve this via other methods

1. If you are on Drupal than you can use views to create the list by sorting created date by descending order.
2. You can also use Data Processor extension to create dashlet or search report with your own columns and sort by created date by descending order.
> 2 votes

---
Tags: civireport, reports, dashboard
---


# Question
Title: (Solved) When adding a new contact, redirected to Civicrm home page
This started after upgrading Civicrm. When I click on any Civicrm menu item, I get redirected to the Civicrm home page. Please advice.

This is the url shown in the browser: /civicrm/contact/add\_reset\_1\_ct\_Individual

# Answer
> 3 votes
Solved. I used a copy of the navigation menu table for first CiviCRM installation and reset the table. Cleared the CiviCRM caches and my browser cache and the admin menu is working properly.

---
Tags: contacts
---


title: Sending email based on tag

text:
# Question
Title: Sending email based on tag
I was wondering whether it is possible to send mass email based on tag. Right now we can select group only. So is it possible to send email based on tag? Is there any extension for that?

# Answer
You can always search for contacts (e.g. contacts with certain tags) and then send an email / mass mailing to all the contacts via CiviMail. Technically CiviCRM would then create a "hidden group" to do that.

However, it is usually preferable to use groups to manage your mailing recipients in order to ensure that contacts can properly unsubscribe from your lists.

Maybe you could change the tags you currently use to groups?
> 2 votes

---
Tags: civimail
---


title: Disabling Breadcrumbs in CiviCRM

text:
# Question
Title: Disabling Breadcrumbs in CiviCRM
I want to disable the CiviCRM breadcrumbs inside the program code for security reasons.

I tried modifying sites/all/modules/civicrm/CRM/Core/DAO/Menu.php by adding `$skipBreadcrumb['type'] = TRUE;` in the `public static function &fields()` function (where $skipBreadcrumb is set).

I also tried commenting out the `public function addBreadCrumb()` and its call in `public function preProcess()` inside the sites/all/modules/civicrm/CRM/Report/Form.php. I know the path sounds incorrect for what I want to do, but it was the only search result for 'breadcrumb' in a function that I could find.

Can anyone give me a hint?

Edit: Probably it was exaggerated to talk of security reasons here. It is more about not making any pages visible as default that users don't need, that is, keeping the (visible) system slim.

# Answer
> 0 votes
Did you tried using Disable breadcrum drupal module?

---
Tags: security
---


# Question
Title: Marking Activities with Priority "urgent" in another color
In the CiviCRM system I work on, activities created for a specific case can have the priority "normal" or "urgent". This attribute is set by the user when creating the activity inside the CaseView. Internally, the "priority\_id" of this activity is set to 1 == "urgent" or 2 == "normal". Now, I want to mark the activities with priority "urgent" in another color when listed in the CaseView as well as in the Case Overview (Cases \> My Cases). I started with the first task (changing the activity layout in the CaseView activity list).

I tried modifying the sites/all/modules/civicrm/templates/CRM/Case/Form/ActivityToCase.tpl at line 23, added the following if-clause. This template is included in sites/all/modules/civicrm/templates/CRM/Case/Form/CaseView.tpl in line 259, which seemed like the correct place in the CaseView.tpl for the activities to appear. I added:

```
{if $form.priority_id == 1}
   <td class="label urgent">{$form.file_on_case_activity_subject.label}</td>
{elseif $form.priority_id == 2}
   <td class="label">{$form.file_on_case_activity_subject.label}</td>
{/if}

```

where before we only had:

```
<td class="label">{$form.file_on_case_activity_subject.label}</td>

```

When this didn't work, I tried to set an "urgent" class to the $form.file\_on\_case\_activity\_subject.html as well:

```
{if $form.priority_id == 1}
          <td class="label urgent">{$form.file_on_case_activity_subject.label}</td>
          <td class="urgent">{$form.file_on_case_activity_subject.html}<br />
            <span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
          </td>
        {elseif $form.priority_id == 2}
        <td class="label">{$form.file_on_case_activity_subject.label}</td>
          <td>{$form.file_on_case_activity_subject.html}<br />
            <span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
          </td>
        {/if}

```

where before we only had:

```
<td class="label">{$form.file_on_case_activity_subject.label}</td>
<td>{$form.file_on_case_activity_subject.html}<br />
            <span class="description">{ts}You can modify the activity subject before filing.{/ts}</span>
          </td>

```

As this didn't work either, I suppose I am modifying the wrong place. Any hint anyone?

Edit: I created an extension with the following code, but it doesn't work yet:

```
function mark_urgent_activities_civicrm_buildForm($formName, &$form) {
  if ($formName == 'CRM_Case_Form_CaseView') {
    CRM_Core_Resources::singleton()->addStyle('#crm-container table.nestedActivitySelector tr.priority-urgent {background-color: orange;}');
  }
}

```

Edit2: Accessing the elements with priority-urgent class works in the css file, both as

```
.priority-urgent {
font-weight: bold;
}

```

and

```
#crm-container table.nestedActivitySelector tr.priority-urgent {
font-weight: bold;
}

```

The (background / font) color doesn't work yet, but I suppose that's only because element cannot have background color.

# Answer
> 3 votes
If I'm understanding correctly, all you need to do is make an extension and call `CRM_Core_Resources::singleton()->addStyle()` in hook\_buildForm as described at https://docs.civicrm.org/dev/en/latest/framework/resources/#css-stylesheets since activities with priority urgent already get class priority-urgent added to the `<tr>` element in the table that lists the activities.

e.g. `CRM_Core_Resources::singleton()->addStyle('#crm-container table.nestedActivitySelector tr.priority-urgent {background-color: orange;}');`

The `#crm-container table.nestedActivitySelector` part is required because otherwise the more specific css target from core gets applied instead.

---
Tags: civicase, activity
---


# Question
Title: Webform Contributions Error Since Last Update
Running Civi 5.28.0, I have recently upgraded Stripe Extension :

* STRIPE PAYMENT PROCESSOR to 6.5.1
* MJWSHARED to 0.9.4

Since then, payments via webforms fail in unexpected Error.

How can I retreive a working configuration ?

# Answer
> 1 votes
Install contribution transaction api extension...

---
Tags: webform-civicrm, stripe
---


# Question
Title: Embed profile in separate Web site (WordPress)
Is it possible to embed a profile (form) in a Web page on a different Web site? My CiviCRM is on a WordPress site, so there is no "MORE" option to capture an HTML snippet when looking at the properties of my Profile. I know I can embed the form in a Web page on the CiviCRM Web site, which inserts something like \[civicrm component="profile" gid="33" mode="create" hijack="1"\]

But obviously that alone won't work if I embed it on a page on another Web site. Is there a way to do this?

\[And if so, do I also need to set "Accept profile submissions from external sites" to yes? Is this a security risk?\]

# Answer
> 1 votes
You need to enable a setting that allows Profile submissions from external sites for this option to be visible.

To do this go to Administer \>\> System Settings \>\> Misc and look for "Accept profile submissions from external sites"

---
Tags: wordpress, profile, forms
---


# Question
Title: How can I create a copy of my CiviCRM site?
Upgrade instructions include:

> Use your backup to create a copy of your site (directories and database), and ensure that this copied site works correctly.

How can I create a copy of my CiviCRM site (on Drupal)? Is there a big difference between making a copy on the same server or another one?

# Answer
There are some instructions at https://docs.civicrm.org/sysadmin/en/latest/misc/switch-servers.

The wiki page referenced in a couple similar questions is still there but getting out of date, and there's something wrong with the styling at the moment, but it's still legible: https://wiki.civicrm.org/confluence/display/CRMDOC/Moving+an+Existing+Installation+to+a+New+Server+or+Location
> 2 votes

# Answer
I wrote instructions on how to do this on the old CiviCRM Wiki in around 2010 for Drupal 6 and then updated it again for Drupal 7. I just had to do it again on a Drupal 7 site and my old instructions were out of date.

The workflow for creating a copy of a Drupal/CiviCRM website with a database for the Drupal site and a database for the CiviCRM database is as follows:

**1)** Copy the CiviCRM data from the Live site with specific options.

**2)** Create a fresh empty Drupal site.

**3)** Copy all of the site assets (files, libraries modules) from the live site to the fresh empty Drupal site.

**4)** Install a clean copy of CiviCRM in the fresh empty Drupal site.

**5)** Copy/Import the Drupal database into the fresh empty Drupal site.

**6)** Import the CiviCRM data from step 1 into the fresh empty Drupal site.

---

**Here is a step by step process of the above:**

---

From the LIVE SITE get a full MySQL dump of the database with the following key options. You can do this with MySQLAdmin or PHPMyAdmin.

**1)** Do **not** copy the following tables:

* civicrm\_acl\_cache
* civicrm\_acl\_contact\_cache
* civicrm\_cache
* civicrm\_domain
* civicrm\_group\_contact\_cache

**2)** Disable foreign key checks

**3)** Add "IF NOT EXISTS" clause under the "Add CREATE TABLE statement"

**4)** Add "Truncate table before insert" option

---

**Install a fresh, blank Drupal website with the same version of the Drupal 7 that the live website uses.**

After it has been installed do the following:

**1)** Copy /sites/default/files from the live site to the local site.

**2)** Copy /sites/all/libraries from the live site to the local site.

**3)** Copy /sites/all/themes from the live site to the local site.

**4)** Copy /sites/all/modules from the live site to the local site **except for the civicrm module**. We will use a brand new installation of CiviCRM to ensure it is clean.

---

**Install CiviCRM in the local site**

Get a fresh download of the CiviCRM version you are using on the live website. Place it in the /sites/all/modules directory and run the installer at: /sites/all/modules/civicrm/install/install.php.

After the installer runs you should have a blank Drupal 7 website and a blank copy of CiviCRM running within it. Check the Admin controls and Drupal's log messages to ensure that the installation is clean and that CiviCRM is running correctly before you proceed to import the website and CiviCRM data.

---

**Migrate/Import the Drupal database into the local site**

Migrate the Drupal database from the existing live site to the new blank local Drupal website. I use the excellent Drupal Backup and Migrate module to accomplish this but you can also do this with a MySQL Dump and import it into the site's drupal database as well.

If you are using Backup and Migrate on the Live drupal site, navigate to the Configuration -\> System -\> Backup and Migrate UI (/admin/config/system/backup\_migrate), clear caches and download a backup of the Drupal site. On the new Local site navigate to the Configuration -\> System -\> Backup and Migrate -\> Restore UI (/admin/config/system/backup\_migrate/restore) and load the backup file that you downloaded and click restore. It may take a couple of minutes but the new local site should take on all of the Drupal features and settings of the Live site.

At this point I clear the site caches on the local site and prepare to import the CiviCRM data.

---

**Import the CiviCRM data**

Importing the CiviCRM data may be problematic. When you exported the CiviCRM database dump, you disabled foreign key checks, added a if not exists clause to the table create clause and you added the option to truncate the table data before importing data so you should be able to simply import the CiviCRM dump from the live site into your local site. I've done it with PHPMyAdmin but CiviCRM is a monster database so I like to use the terminal window with the following command:

> mysql -u db\_user\_account -p civicrm\_database\_name \< path-to-the-civicrm-dump.sql

---

**Post import housekeeping**

Once the Data has imported there are a few small things that need to be attended to:

**1)** delete the **templates\_c** directory from the /sites/default/files/civicrm directory.

**2)** Clear the caches from CiviCRM, Clear the Drupal caches.

**3)** Make sure that your Resource URL's are correct. They will more than likely be set to the live website's resource URL settings.

**4)** Synchronize users to contacts

**5)** Go to the configuration checklist and make sure that it is correct.

**6)** Go to CiviCRM Admin -\> System -\> CMS Integration and copy any custom fields that you need to add to the /sites/default/settings.php file that are necessary for Drupal Views integration.

---

That should do it.
> 2 votes

# Answer
Andrew's answer is very comprehensive but in some cases you might opt for a simpler approach.

This answer assumes the goal is to set up a "Clone" of the site for testing/development. It also assumes you have ssh/command line access.

The goal is an exact copy of your live site. So you need to sync a few things.

* Codebase
* Database
* Uploaded files

**Uploaded Files**

1. If you are using Drupal's stagefileproxy module, and not uploading much as files into civicrm you can often get away without copying files over.
2. If you are using nginx and your dev site and production are on the same server you can use nginx's try files directive to check first in sites/default/files (or similar) then look under the live site. Note: this isn't going to work for private files.
3. Copy files across. Using rsync can avoid you copying files that exist already. Be kind to the planet and your bandwidth limits at the same time!

rsync -avz --progress files destserver:destdirectory/sites/default/files/

Be careful with your trailing slashes and perhaps do a --dry-run first.

**Database**

Depending on your setup you might have your civicrm in a different database. If so don't forget to update the settings.php aliases mapping after you have finished if you have new custom field groups and are using civicrm drupal views/webform integration.

Things to be aware of. Civicrm uses sql triggers and some sites will have functions and views. When exported these include the username that "defined" them. This will result in issues unless you have a duplicate username/host on the destination machine. And you definitely don't want to load these back into the same machine.

You can strip these out with the mysqldump however I recommend making a practice of using the following perl one liner - that way if you forget this. Or get a dump from someone else who hasn't run it you wont hit issues.

How do I safely export my database and import it on a new server?

```
perl -pi -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' /path/to/mysqldump.sql

```

pv - if you have a large civicrm database pv is your friend. It will give you a very limited idea on how long the import will run for - and for the modern generation that are not used to waiting for things to run in the background with no feedback (that's me) give you some reassurance that everything is going to plan.

On debian aptitude install pv

pv reads from stdin (or the filename provided as an argument) outputs to stdout and prints a progress bar in the terminal.

generate your dumpfile from live via:

In MySQL 5.7.8+ you can use --skip-definer

```
mysqldump --single-transaction databasename  | pv |  gzip > databasename.sql.gz

```

Top tip - Have massive log files but don't need them on your copy - then

```
mysqldump --single-transaction databasename $(mysql -BN -e "select table_name from information_schema.tables where table_schema = 'dbname' and table_name not like 'log_civicrm%'")  | pv | gzip > databasename.sql.gz

```

Load the database into mysql. If you are refreshing your copy from live easiest to just drop the existing database - top tip make sure it's the right one, and maybe back it up first...

You might want to run the load step in steps.

```
mysql -e "drop database databasename"
mysql -e "create database databasename"
pv databasename.sql.gz | gunzip | | perl -p -e 's#\/\*\!5001[7|3].*?`[^\*]*\*\/##g' | mysql databasename

```

**Codebase**

The initial copy can be everything but you'll need to update civicrm.settings.php and settings.php subsequent copies a git based workflow works well in drupal 7. Drupal 8/9 offer composer based workflows.
> 2 votes

---
Tags: upgrade, backups
---


title: Anonymous role cannot make contribution

text:
# Question
Title: Anonymous role cannot make contribution
Help wanted – Suddenly, our donation and membership pages are stop working (the credit card fields are gone). Anonymous role cannot make contribution or sign up for membership. When an anonymous user filled out all the required screens, clicked on “review your contribution” and was given this error: Payment Method is a required field. I am using WordPress 5.5.1, IATS and CiviCRM 5.29.1. I checked the Access Control (Permissions) in WordPress; it shows anonymous role can” Make payments or donations through your (our) website”.

Please help. Thank you.

# Answer
> 1 votes
I have had a similar problem with a WordPress install. In my case the *Anonymous* role of WordPress missing.

The Wordpress roles can be checked with

```
wp role list

```

I created the new role with

```
wp role create anonymous_user 'Anonymous User'

```

---
Tags: wordpress, civicontribute, civimember, iats
---


# Question
Title: 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 altering an SQL call in sites/all/modules/civicrm/CRM/Case/BAO/Case.php::getCaseActivity(). So if I want to create an extension for that, I would need a hook function that will be called whenever sth is read from a database table. I checked all the hooks in https://docs.civicrm.org/dev/en/latest/hooks/ but couldn't find a suitable one.

Is there a hook function like that? Is there a more specific alternative to save resources (checking the hook extension each time a database table is called would happen lots of times)?

Can I create custom hook "call points" to determine at which line of code a hook is called?

# Answer
> 0 votes
There is no hook for reading data from the database. There are hooks however for rendering forms and pages.

There is also a hook for api v3 which is called before and after each api call. That hook is called apiWrapper

---
Tags: hooks
---


title: How do I rename a report

text:
# Question
Title: How do I rename a report
I have copied a report which shows the title as "Copy plus the report name"

How do I change the name of this copy?

# Answer
> 2 votes
When viewing the report results click on the Title and Format tab at the top. Change the name. Then from the actions dropdown below the Refresh Results button choose Save.

---
Tags: custom-reports
---


title: Bookkeeping in 5 Minutes a month

text:
# Question
Title: Bookkeeping in 5 Minutes a month
With all the integrations out there, there's no reason bookkeeping should take more than five minutes a month, without a bookkeeper.

Does anyone have a system for this that doesn't require lot's of manual work, and still imports all the important information into Quickbooks?

I have some ideas, but want to hear from you first.

thanks in advance

# Answer
I agree with what you said at the start of your paper, "QB looks at money from the perspective of the business (the primary concern is where the money is coming from, going to, profit and loss, health of business, successful/failing programs). The people who gave the money are only incidentally important. Civi (or any CRM) is primarily dealing with people."

Because of this...We do not export our donor data to QuickBooks. We do not see the need to record who gave the money in both places. QB only holds the deposit information--when, how much and what campaign/fund the deposit is split into.

**In Civi** we have Financial Type to mark our Master categories:

Donations (Tax deductible), Tuition (Not tax deductible), Event Fees (Not Tax deductible), *This is useful for reports where you want to see all tuition payments for x time period*

Line items are our fund accounts: General Fund, Capital Campaign, Scholarship, Event ABC, *This allows us to drill down into more detail as needed*

**In QBs** We use: *Customer* = Fund accounting, this allows us to show income and expenses tied to our fund accounting. We can demonstrate to donors how much came in and how those funds were spent according to their designation. *Class* = Functional Expense tracking, with each expense we apply it to Program, Management and Fundraising. At the end of the year when we do our 990, everything is already labeled. No need to estimate. *Department* = Budget categories that different staff oversee.

This allows us to overcome QBs inability to truely handle fund accounting.

YES, as you pointed out we have to use a special report to split the deposits into the different funds/campaign before entering it into QB. We have developed a Drupal View that helps our Accounts Receivables more easily create the QB deposit entries from CiviCRM.

For my feedback: I am fine with your idea as an extension, it looks well thought out for your case use. I would make the argument that your paper starts off with the correct premise but then turns from that and treats QBs as a CRM--something it is not.

Thanks for taking the time to think through and write out your ideas on improving Civi!
> 2 votes

# Answer
It may be worth exploring the Civi extension already in place

https://civicrm.org/extensions/quickbooks-online-civicrm-contribution-and-contact-synchronization

It states

> QuickBooks Online provides different Tax APIs for US and non-US countries. This extension has been developed and tested for QuickBooks Online, Australia. With initial development and testing to support QuickBooks Online, US.

So depending on your locality it may already be meeting your needs.
> 1 votes

---
Tags: bookkeeping, quickbooks
---


# Question
Title: Missing information when Importing Contributions via API
I want to import a list of contacts from a csv file (specifically: the Contact IDs), and create a Contribution via API for each one of them. Purpose: These contacts are all ordering the same articles, but have not yet ordered via the CiviContribute system, so we need to import the data.

I wrote a PHP script for that, which is saving the new Contribution correctly on each Contact. It contains the following API call:

```
civicrm_api3('Contribution', 'create', [
        'financial_type_id' => 11,
        'receive_date' => 20201008150000,
        'total_amount' => 11.15,
        'contact_id' => $civicrm_id,
        'contribution_status_id' => "Pending",
        'payment_instrument_id' => "Überweisung",
        'is_pay_later' => 1,
        'price_set_id' => 25,
        'skipLineItem' => 1,
        'api.line_item.create' => [
          '0' => [
            'price_field_id' => 55,
            'qty' => 1,
            'label' => 'article name example 1',
            'line_total' => 8.57,
            'unit_price' => 8.57,
          ],
          '1' => [
            'price_field_id' => 56,
            'qty' => 1,
            'label' => 'article name example 1',
            'line_total' => 2.05,
            'unit_price' => 2.05,
          ]
        ]
      ]);

```

But it makes two mistakes:

* The value in the "Item" column in the Contribution View and the Invoice is a default value "line item". I manage to solve this by adding the article name into the code (`'label' => 'article name example 1'`), but it should be automatic.
* The tax is not added in the Contribution View and the Invoice. I think this shows that the new Contribution is not properly connected with its Financial Type (or Price Set?), because the tax is calculated automatically depending on the Financial Type, I think. I added the `'financial_type_id'` to the api Call, but the problem persists.

Any hint anybody?

# Answer
This should work

```
civicrm_api3('Contribution', 'create', [
    'financial_type_id' => 11,
    'receive_date' => 0201008150000,
    'total_amount' => 11.15,
    'tax_amount' => 0.53,
    'net_amount' => 10.62,
    'contact_id' => $civicrm_id,
    'contribution_status_id' => "Pending",
    'payment_instrument_id' => "Überweisung",
    'is_pay_later' => 1,
    'skipLineItem' => 1,
    'api.line_item.create' => [
        'entity_table' => 'civicrm_contribution',
        'contribution_type_id' => 11,
        'financial_type_id' => 11,
        'price_field_id' => 55,
        'label' => 'article name example 1',
        'tax_amount' => 0.53,
        'unit_price' => 10.62,
        'line_total' => 10.62,
        'non_deductible_amount' => 0.00,
        'qty' => 1.00,
      ]
  ]);

```
> 0 votes

---
Tags: civicontribute, api
---


# Question
Title: How can I bulk update the contact employer based on the employee relationship?
I want to bulk update the Employer field for the Individual contacts who have an active relationship of "employee of".

Even though we have many active employee relationships for individuals, the Employer field is blank.

# Answer
> 2 votes
You can do this directly in the database by running the following update query:

```
UPDATE civicrm_contact,
  (civicrm_relationship r
    LEFT JOIN civicrm_contact c ON c.id = r.contact_id_a)
  LEFT JOIN civicrm_contact c1 ON c1.id = r.contact_id_b
  SET c.employer_id = r.contact_id_b,
      c.organization_name = c1.organization_name
  WHERE r.relationship_type_id = 5
    AND c.contact_type = 'individual'
    AND c.employer_id IS NULL
    AND r.is_active = 1;

```

This will update the employer field for all individual contacts who have an active employee relationship and do not have an employer already set.

# Answer
> 2 votes
This is building on Ben's answer, but should run substantially faster.

```
UPDATE civicrm_contact employeeContact
  INNER JOIN civicrm_relationship r ON employeeContact.id = r.contact_id_a
  INNER JOIN civicrm_contact employerContact ON employerContact.id = r.contact_id_b
    SET employeeContact.employer_id = r.contact_id_b,
        employeeContact.organization_name = employerContact.organization_name
  WHERE r.relationship_type_id = 5
    AND employeeContact.contact_type = 'Individual'
    AND employeeContact.employer_id IS NULL
    AND r.is_active = 1;

```

In my use-case I have several qualifying relationships, e.g. "is staff at" and "is intern at", so I changed the `r.relationship_type_id = 5` for `r.relationship_type_id IN (x, y, z)`. You can get the `x, y, z` IDs from the **Administer » Customise Data and Screens » Relationship Types** table. Just hover your mouse over the View link and look at the `id=` URL parameter.

Please note that this code only works if the Individual (employee) is on the A-side of the relationship.

You could use the SQL Tasks extension to automate this.

---
Tags: contacts, relationships
---


# Question
Title: What time of day are Scheduled Reminder Event Emails sent?
The 'Scheduled Reminders' tab for events allows the user to set an exact date for a Scheduled Reminder Email to be sent, but there is no option to specify a particular time on that date.

What time of day are such emails sent by civi? Is it 12:00am on the day? Because this is the first time that it is true that the date matches? Or is there some other default time set?

# Answer
This varies but is configurable.

If you go to **Administer menu \> System Settings \> Scheduled Jobs** you'll see a job called *Send Scheduled Reminders*. It will also say what time the job was last run. It will run 24 hours from the last time it was run.

You can edit the job to force it to run next at a given time. It will then run 24 hours from when it was previously run.

A good improvement would be to allow specifying a time, which should be possible these days - CiviCRM stores a time internally to deal with timezone issues. This would be especially helpful for users who have modified the scheduled job I mentioned above to run more frequently than daily.
> 3 votes

---
Tags: civievent
---


# Question
Title: cf-civicrm State/Province field dropdown not populating after country is chosen
I've just started working with the cf-civicrm plugin so I may be missing something simple.

I can't get the CiviCRM State/Province select field to fill. I tested it using the "CiviCRM Contact and Address" form template after running into the issue on a form I was building. No luck. The field just returns N/A for every country I've tried.

My experience has some parallels to this github issue but the fix that worked for rbaugh isn't working for me.

Questions, tip and pointers about how to resolve this would be most welcome.

Thanks!

# Answer
> 5 votes
This type of problem commonly occurs when any of these is true:

1. No default country is set
2. No default state is set
3. Available countries is not set - list on right-hand side is empty
4. Available states is not set - list on right-hand side is empty

Check your CiviCRM Localisation Settings. Below is a screenshot of a working configuration for a site in Australia that allows both Australia and USA country/state options to be selected.

# Answer
> 2 votes
Making sure that Localisation is set is the first step.

On the form itself, you need to define a country field:

and then the State/Province Field. In the State Field be sure you are linking to the Country Field:

# Answer
> 2 votes
I have it working and, at least in my case, the issue is with the handling of available countries and available states as rbaugh describes in this github issue. Essentially, if you leave the right-hand box empty to include all countries (as the CiviCRM note directs), none of the states are loaded. Loading all of the countries into both right-hand boxes works.

Commenting out the foreach loop from lines 293 to 297 in cf-civicrm/includes/class-civicrm-caldera-forms-helper.php allows the fields to work in the form with the available countries right-hand box empty (with the available states empty as well).

My usage is worldwide. I need all the countries so this hack works for me but it looks like the logic around that foreach loop needs some refinement.

Along the way I did some tests.

* It works fine with no default country or state. Only the available countries and available states mattered. (See Justin Freeman's reply above.)
* Since I have only one pair of Country/State fields, the CiviCRM Country field in the State field parameter list has no effect. (See Kevin Cristiano's reply above.)

I'll report what I'm finding on the cf-civicrm github site.

---
Tags: caldera-forms
---


# Question
Title: Has anyone had any success integrating CiviCRM into Craft CMS?
We have a potential client whose site is currently using CiviCRM and Drupal. They are interested in using Craft CMS. I've researched other CRM plugins for Craft similar to CiviCRM but they do not exist. We would like to stay with CiviCRM but has anyone had any success integrating the two?

Thanks S.

# Answer
> 3 votes
I would strongly expect the answer to be No simply because integrating with a CMS is a big task and the only 3 that are officially done are WP Joomla and Drupal as I am sure you are aware. There are however solutions for having CiviCRM separate from a CMS but still have forms etc available eg

Remote Forms

CiviCRM Modular Remote-Access Framework

# Answer
> 2 votes
I think it depends on what's meant by "integration". CiviCRM can install as a plugin to Drupal/Backdrop/Joomla/WordPress, which gives certain integration points, but that's not the only way to integrate CiviCRM.

As Pete points out, there's Remote Forms and CiviMRF for integrating with any site. There's also Form Processor and Data Processor if you have complex needs. E.g.:

* I intend to use Form Processor to allow a remote site to open new cases in CiviCRM for a client.
* For another client, I intend to use Data Processor to display a membership directory and map based on real-time Civi data on a remote site. That site is WordPress, so I'm using Content Views CiviCRM and Leaflet Map plugins to simplify things on the remote site - but Craft has its own JSON viewers.

# Answer
> 1 votes
Anything is possible if you've got the time and resources but if you are looking for a dependable and cost effective solution to use CiviCRM on a website, you are going to have to use Drupal, Wordpress or Joomla.

I would find out why the client wants to use Craft as opposed to Drupal. More likely than not it's because their Drupal site is poorly configured and they aren't getting the most out of it. My plan would be to do a deep dive with the client to assess their use of the site, how the site is configured and come up with a plan to make it work for them.

You could put CiviCRM on a headless Drupal instance and build an API endpoint to communicate with the Craft site but that seems like an awful lot of work for very little return.

---
Tags: cms-integration
---


title: Why does my CSV export use semi-colons?

text:
# Question
Title: Why does my CSV export use semi-colons?
A simple search and then use the export option from the drop down generates me a csv file that isn't - i.e. it's a semi-colon separated values file, not commas. There doesn't seem to be any setting that does that, and it seems to be specific to one site.

CiviCRM 5.28.4, Drupal 7.73

# Answer
> 1 votes
Thanks to @samuelsolv for his answer to Export contact info from MailChimp

Apparently, the separator for import/export of csv files is a "localization" setting, at this path:

/civicrm/admin/setting/localization?reset=1

---
Tags: export
---


# Question
Title: Form Processor on WordPress - undefined offset: 1
I have a Form Processor set up to take newsletter signups on a WordPress.com website. The CiviCRM site is hosted separately.

It was working until recently and I've tried twice to retrace my steps but I've still not got it working.

When I test the Form Processor on the CiviCRM Site, it works as expected (matches to existing contact if present, adds group, adds Data Policy Acceptance Activity, updates one custom field).

I've checked the settings for the Contact Form in WordPress.

When I fill in the form on the WordPress site:

* It just hangs, and nothing is stored in CiviCRM
* The debug file says

> \[10-Oct-2020 12:59:14 UTC\] PHP Notice: Undefined offset: 1 in /srv/htdocs/wp-content/plugins/contact-form-7-civicrm-integration/contact-form-7-civi.php on line 59

This is lines 57-63 in the file mentioned:

```
  foreach($parameters as $param) {
    list($key, $val) = explode("=", $param);
    if (!empty($key)) {
      $data[$key] = $val;
    }
  }

```

Any ideas what I need to change/what I've missed?

# Answer
> 0 votes
If $param doesn't have an `=` in it then the list() wouldn't have an offset 1 element. Can you debug $param?

---
Tags: wordpress, form-processor
---


title: Can't pay for Civi Event using Stripe

text:
# Question
Title: Can't pay for Civi Event using Stripe
I am trying to configure CiviEvent, but have a problem and don't know where to look.

* I have two test sites, as far as I can see both configured the same. CiviCRM 5.29.1, Stripe 6.5.1. Simple test Event set up.
* On One site I can configure Events that work OK if not paid for or paid for using credit card with Stripe (with a test card only so far). On the other it works if not paid for, but Stripe fails.
* When failing it flashes up the 'Wait while Pre-authorising' message, but then returns to the registration page asking to have the card number put in again.
* When failing the Stripe log shows an Authorised but Uncaptured payment.
* There are no errors in the Drupal log.

Can anyone suggest anywhere to look that might help find this problem? Thanks.

# Answer
It looks like this is a side-effect of a custom Module we have installed for something else (still related to Events). Consider this question closed.
> 2 votes

# Answer
I would look in your Stripe dashboard at "Events" (found under the "Developer" section of the navigation menu). You're likely to find an event associated with the failure with an error message in its details.

Also, errors on your end are much more likely to be in the CiviCRM log than the Drupal log.
> 1 votes

---
Tags: civievent, payment-processor, stripe
---


title: custom public participant listing

text:
# Question
Title: custom public participant listing
we use wordpress and civicrm to allow our members to register for sports events.

I would like to display in an article for all authenticated member, the list of registered people to all of the week events.

My first intention was to custom or create a public participant list that already exist but :

* it is only for one event
* I don't know how to add the Role (ie Animateur or Participant or Invité) and the comment of the participant (both information entered in the custom profile registration)

Need your advise

Regards, Hervé

# Answer
> 2 votes
I would use content views wordpress plugin along with content views civicrm integration plugin and data processor civi extension to list what you want.

---
Tags: wordpress, civievent
---


# Question
Title: Sales Tax not added to total when memberships include donations that are separate transactions
We are having a problem with sales tax calculations when letting the user add an optional donation to a membership purchase or renewal. We need to separate the membership and donation into two transactions (selecting "Separate Membership Payment" on the membership tab of the contribution page) so that the the charitable donation receipt will be generated. If we don't separate the payment, the sales tax is computed properly -- but then we can't generate a charitable donation receipt.

When we separate the transactions, the sales tax is not added to the membership purchase, but it does appear on the receipt but is not added or charged.

On the contribution page:

* Financial type is set to Donation - that type will generate a charity receipt, but no sales tax
* "Contribution Amount section enabled" is selected to let the user enter a donation with membership, with "allow other amounts" selected so that they can enter what they want
* "Separate Membership Payment" is selected, as described above

For example, if we select a $90 membership that needs $11.70 sales tax with an $100 extra donation:

Receipt 1 (for membership), shows sales tax but it is not added to the total:

Receipt 2 (for donation) shows no sales tax and is correct:

I have tried the patch but that didn't make a difference.

I am using WordPress 5.5.1 and CiviCRM 5.29.1 with CiviMember and CDN Tax Receipts extension.

# Answer
> 0 votes
Looks a bug - can you log an issue in gitlab - https://lab.civicrm.org/groups/dev/-/boards

---
Tags: civicontribute, civimember
---


# Question
Title: Wordpress - Civicrm 5.16 upgrade to 5.30 issue - Notice: Undefined index query in /wp-content/plugins/civicrm/civicrm.php on line 483
When upgrading our site from Civi 5.16 to the latest 5.30, when I point my browser to run the upgrade at: http://example.org/wp-admin/admin.php?page=CiviCRM&q=civicrm/upgrade&reset=1

I get the to the update page, which has the following:

The database will be upgraded from 5.16.0 to 5.30.0.

Then long list of warnings about default copies of message templates etc. At the end of this, when I click on the "Upgrade Now" button, I get this message and nothing else happens:

Notice: Undefined index query in .../wp-content/plugins/civicrm/civicrm.php on line 483

I'm running Wordpress 4.9. No our site is down and I need help to resolve this upgrade issue.

# Answer
Comment out line 391 of that file - so that it reads like this:

```
// add_filter( 'heartbeat_settings', array( $this, 'heartbeat' ), 1000, 1 );

```

Then try the upgrade again.
> 0 votes

---
Tags: upgrade
---


# Question
Title: Hook postProcess doesn't work with message templates form
I'm trying to add a couple of fields to the message templates ("CRM\_Admin\_Form\_MessageTemplates") in a custom extension. I use the "buildForm", "validateForm" and the "postProcess" hooks. The "buildForm" and the "validateForm" hooks works perfectly but the "postProcess" hook does nothing. I'm using civicrm 5.27.4 and drupal 7.72. I tried it also on a other installation but same results. I also tried it with a other clean custom extension but that also doesn't work. And the same hook works on other forms. Can someone help me?

# Answer
> 1 votes
Yes, some admin config forms doesn't invoke postProcess hook. Try below patch to invoke post process hook

```
diff --git a/CRM/Admin/Form/MessageTemplates.php b/CRM/Admin/Form/MessageTemplates.php
index 5f809f2..67cac30 100644
--- a/CRM/Admin/Form/MessageTemplates.php
+++ b/CRM/Admin/Form/MessageTemplates.php
@@ -309,6 +309,7 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Core_Form {
       }

       $messageTemplate = MessageTemplate::save()->setDefaults($params)->setRecords([['id' => $this->_id]])->execute()->first();
+      $this->postProcessHook();
       CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', [1 => $messageTemplate['msg_title']]), ts('Saved'), 'success');

       if (isset($this->_submitValues['_qf_MessageTemplates_upload'])) {

```

---
Tags: hooks, message-templates
---


# Question
Title: What does it mean to "configure your MySQL server for utf8mb4 support" when my database charset and collation are already utf8mb4?
I am about to run the CiviCRM installer, but I get the following warning:

CiviCRM MySQL utf8mb4 Support: It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb\_large\_prefix=true innodb\_file\_format=barracuda innodb\_file\_per\_table=true

However, my database configurations are already as follows:

So what exactly is "MySQL utf8mb4 Support" and what are the steps to configure it properly? (e.g. what do I do with this exactly? "innodb\_large\_prefix=true innodb\_file\_format=barracuda innodb\_file\_per\_table=true")

# Answer
> 2 votes
You need to put those in your mysql configuration file (e.g. sometimes located at /etc/my.ini, depends on your host) as described at https://docs.civicrm.org/installation/en/latest/general/requirements/#mysql-configuration

```
[mysqld]
innodb_large_prefix=true
innodb_file_format=barracuda
innodb_file_per_table=true

```

If you don't have access to that you'll need to ask your hosting company.

At the time of writing (civi v5.30), all this does is make it possible to use utf8mb4, but civi will still install as utf8. After install, you can manually convert by choosing the menu option Support - Developer - Api explorer v3, and choosing `Entity: System` and `Action: utf8conversion` and then clicking the Execute button.

---
Tags: database, installation, configuration
---


# Question
Title: What should I do about Deprecated Functions?
My log is largely full of various warnings about deprecated function calls, from both CiviCRM core and extensions. They do not seem to cause direct problems, but finding genuine problem messages among all the noise is difficult, and there is a worry that the support for the deprecated version will be withdrawn before the calling code is fixed.

I have raised a PR on GitHub with a fix for one simple case (so far without response), but in general I don't know enough about the problem to be confident trying to alter the code correctly.

# Answer
All you can really do is log an issue or PR. You're right they don't hurt anything but yes they'll need to be fixed by the extension/core eventually.

If you want to turn them off temporarily you can hack CRM/Core/Error/Log.php to just return instead of logging them, but of course they'll come back when you upgrade if they aren't fixed yet.

I'll note though that the logging is also there in the situation where it was marked deprecated but it's not known fully if anyone has a configuration where it's used, and so the hope is they'll report it.
> 0 votes

# Answer
Note: this answer is wrong, as @demerit correctly points out in his polite comment. I've added a followup below.

\[wrong!\]

Deprecated notices are logged only if CiviCRM thinks you're running a development environment. Unfortunately, CiviCRM's test for that isn't very smart, and in particular, if you've pulled your CiviCRM code from a git repo, it thinks you're running a development environment.

Try removing or temporarily renaming that .git directory.

I can't remember where or when this was noted previously, that test does need to be improved.

I agree that they're not useful notices when running a production environment, they're really designed for automated testing only.

\[/wrong\]

It would be nice to not log deprecation notices on a production site. At the moment I think you'd have to do that by editing /CRM/Core/Error/Log.php at our about line 57.
> 0 votes

---
Tags: logs
---


# Question
Title: CiviCRM MailChimp Integration - sync with MailChimp fails
hope you're well. New user of the MailChimp integration extension available here: https://civicrm.org/extensions/mailchimp-civicrm-integration

We are attempting to integrate CiviCRM 5.29.0 on Wordpress and MailChimp, but we get this error when we perform the test sync (see image). As you can see (despite blurring out the info) it is able to pull MailChimp information but errors out with the 2nd error below it.

I found this page here that suggested the problem might be a lack of a Anonymous User user with webhook permissions in CiviCRM but couldn't find anything about explicitly adding webhook permissions to a role. Struggled to find in this page what exactly I need to permit in order to grant the right permissions. How to make the callback URL from Mailchimp accessible from anonymous users in Wordpress?

Could someone point me in the right direction for a guide on how to set up CiviCRM 5.29.0 for this MailChimp integration?

Thanks everyone :)

# Answer
Check the CiviCRM WordPress Permissions page, you need to enable Anonymous Role the permission to execute the Mailchimp Webhooks.
> 1 votes

---
Tags: mailchimp
---


# Question
Title: Pre-header text for mosaico mailings shows twice
When using the Pre-header Text option in a Mosaico mailing like this:

The preheader text shows twice in gmail like this:

Is there a way to stop this happening?

# Answer
Basically, from what I can see in the code ( see Mosaico github issue for details here https://github.com/voidlabs/mosaico/issues/582 ) preheader is being conditionally shown depending on "Unsubscribe" link behaviour and display logic in template-versafix-1.html have a flow.

One possible workaround is to set Unsubscribe link value to anything but "None" (both "Unsubscribe" and "Profile" would work) and (optionally) delete Unsubscribe link & text from preheader block
> 2 votes

---
Tags: mosaico
---


# Question
Title: Export full state name - not abbreviation
In the CiviCRM database the States have a full name and an abbreviation. e.g. New York, NY; Paris, 75; British Columbia, BC.

The contact export on CiviCRM exports the abbreviation for the state field not the full state name. This is fine for US and Canada but doesn't work fore UK and Ireland.

I've used CiviToken which has a token that adds the full name. But this is only good for labels and templates. I need an export to do an offline mail merge for a printer.

I've found this from searching but nothing since https://forum.civicrm.org/index.php%3Ftopic=21897.0.html https://forum.civicrm.org/index.php%3Ftopic=28789.0.html

Is there a way to do this?

Could it be added as a core feature. It's a function that anyone in UK and Ireland would need.

I'm on CiviCRM 5.14.1

All the best James

**25 Nov 2021: Update on this issue:** In Nov 2020 I did the changes suggested above in https://civicrm.stackexchange.com/a/37952/8411

* copied civicrm\_state\_province name to civicrm\_state\_province abbreviation for all countries apart from US and CA.
* changed field civicrm\_state\_province abbreviation and log\_civicrm\_state\_province abbreviation to varchar(64)

A few months ago the State / Province field stopped loading the saved values from the database on the webforms where users edit address. They still saved the values.

Now after upgrading to CiviCRM 5.43.2 I started getting an error “State cannot be longer than 5 characters but is currently 10 characters long.” when saving the webform. This isn’t coming from the database as I changed the field civicrm\_state\_province abbreviation to be varchar(64) as noted above. New validations of the state field for 4 characters must have been introduced in the code.

I implimented this solution. I reverted the changes above to the abbreviation field. Instead I edited code to get the export function to return civicrm\_state\_province name instead of abbreviation. Details follow:

```
/httpdocs/sites/all/modules/civicrm/CRM/Core
PseudoConstant.php
function stateProvinceAbbreviation
$query = "SELECT abbreviation
replaced
$query = "SELECT name

```

It would be great if this could be done in the core. Or if the core export function could export the civicrm\_state\_province name and abbreviation instead of just abbreviation.

This must be an issue for a lot of users outside USA and Canada where these abbreviations are not commonly used.

# Answer
> 2 votes
The more general issue about state has come up before, e.g. https://lab.civicrm.org/dev/core/-/issues/724 and https://lab.civicrm.org/dev/core/-/issues/1709.

It's not a full solution but you can manually update the abbreviations in the database in the civicrm\_state\_province table, but you'd have to change the column size in the table definition, and someday an upgrade might wipe out your changes, although unlikely.

---
Tags: export, addresses
---


# Question
Title: Why does phpunit say "DB Error: connect failed" for new 'drupal-clean' site?
I have a new 'drupal-clean' civibuild site which works fine in the browser, yet when I try to run civicrm phpunit tests, I get a mysql connection error, "DB Error: connect failed". How can I avoid this and run tests successfully?

Background: I've used civibuild happily for some years now, and have run civicrm tests on this environment in the past, though not within the past few months.

Steps I've taken to help ensure I'm really starting from scratch (actual copy-paste output from terminal, just now):

```
10:57 $ cd /opt/buildkit

10:57 $ git remote -v
origin  git@github.com:twomice/civicrm-buildkit.git (fetch)
origin  git@github.com:twomice/civicrm-buildkit.git (push)
upstream    https://github.com/civicrm/civicrm-buildkit.git (fetch)
upstream    https://github.com/civicrm/civicrm-buildkit.git (push)

10:59 $ git fetch upstream

10:59 $ git checkout upstream/master
HEAD is now at 4b3be16... Merge pull request #572 from seamuslee001/contact_layout_download

10:59 $ ./bin/civi-download-tools
WARNING: The following data-files are not owned by your user, which may lead to permission issues. You may need to delete or chown them.
$ find /home/as/.cache ! -user as
find: ‘/home/as/.cache/shotwell’: Permission denied
/home/as/.cache/pip
[... EDITED OUT: lots of files under /home/as/.cache/pip ...]
[[Composer binary (/opt/buildkit/bin/composer) already exists. Skipping.]]
[[composer dependencies already installed. Skipping.]]
[[npm dependencies already installed. Skipping.]]
[[hub (/opt/buildkit/extern/hub) already exists. Skipping.]]
WARNING: Failed to find recommended PHP extension "imap".
WARNING: Failed to find recommended PHP extension "soap".

11:02 $ civibuild destroy drupal-clean
WARNING: Failed to find recommended PHP extension "imap".
WARNING: Failed to find recommended PHP extension "soap".
[[Load saved options from /opt/buildkit/build/drupal-clean.sh]]
Are you sure you want destroy "/opt/buildkit/build/drupal-clean"? [y/N] y
chmod: changing permissions of '/opt/buildkit/build/drupal-clean/web/sites/default/files/civicrm/persist/contribute/dyn': Operation not permitted
[ ... EDITED OUT: lots more similar permission errors ...]

11:06 $ sudo chown -R as:as /opt/buildkit/build/drupal-clean/web/sites/default/

11:06 $ civibuild destroy drupal-clean
WARNING: Failed to find recommended PHP extension "imap".
WARNING: Failed to find recommended PHP extension "soap".
[[Load saved options from /opt/buildkit/build/drupal-clean.sh]]
Are you sure you want destroy "/opt/buildkit/build/drupal-clean"? [y/N] y
Skip (root=/home/as/.amp/canary, name=, dsn=mysql://canary_jfliz:RZTEqGwHenB5hvw6@127.0.0.1:3306/canary_jfliz?new_link=true)
Skip (root=/opt/buildkit/build/drupal-demo-upgrade, name=cms, dsn=mysql://drupaldemo_xi1bz:p9sSXFAoQWtQWBXq@127.0.0.1:3306/drupaldemo_xi1bz?new_link=true)
Skip (root=/opt/buildkit/build/drupal-demo-upgrade, name=civi, dsn=mysql://drupaldemo_durf6:5BFZ8k7DFqz1Vhl9@127.0.0.1:3306/drupaldemo_durf6?new_link=true)
Skip (root=/opt/buildkit/build/drupal-demo-upgrade, name=test, dsn=mysql://drupaldemo_fwg09:gHQTx18KUAP0mWlu@127.0.0.1:3306/drupaldemo_fwg09?new_link=true)
Skip (root=/opt/buildkit/build/wp-demo, name=cms, dsn=mysql://wpdemocms_vg6e1:JNKQtnQuLoPjy1he@127.0.0.1:3306/wpdemocms_vg6e1?new_link=true)
Skip (root=/opt/buildkit/build/wp-demo, name=civi, dsn=mysql://wpdemocivi_lti76:L8Z5oSsVNIWJ6o5H@127.0.0.1:3306/wpdemocivi_lti76?new_link=true)
Skip (root=/opt/buildkit/build/wp-demo, name=test, dsn=mysql://wpdemotest_e9znx:Wy0GXjWUR8Uzh1Aw@127.0.0.1:3306/wpdemotest_e9znx?new_link=true)
Skip (root=/opt/buildkit/build/universe, name=cms, dsn=mysql://universecm_4nnv1:hu1xzZuDmOjHKWvI@127.0.0.1:3306/universecm_4nnv1?new_link=true)
Skip (root=/opt/buildkit/build/universe, name=civi, dsn=mysql://universeci_7xjxh:0hoMsYdDASKViX4B@127.0.0.1:3306/universeci_7xjxh?new_link=true)
Skip (root=/opt/buildkit/build/universe, name=test, dsn=mysql://universete_sus8o:7AZhYqfN3pKmmASM@127.0.0.1:3306/universete_sus8o?new_link=true)
Destroy (root=/opt/buildkit/build/drupal-clean/web, name=cms, dsn=mysql://drupalclea_f3qli:aYrs9Zbz58LC6vfI@localhost:/drupalcleancms_w6ifm?new_link=true)
Destroy (root=/opt/buildkit/build/drupal-clean/web, name=civi, dsn=mysql://drupalclea_q2x49:kPQax5KCbBSpSiMX@localhost:/drupalcleancivi_dy8w0?new_link=true)
Destroy (root=/opt/buildkit/build/drupal-clean/web, name=test, dsn=mysql://drupalclea_178yz:zMEh3p6ooZDzpfYc@localhost:/drupalcleantest_vm9nd?new_link=true)
Destroyed 3 instance(s)

11:06 $ ls /opt/buildkit/build
drupal-demo-upgrade  drupal-demo-upgrade.sh  universe  universe.sh  wp-demo  wp-demo.sh

11:07 $ civibuild create drupal-clean
[ ... EDITED OUT: lots of civibuild output ... ]
[[Show site summary (drupal-clean/default)]]
 - CMS_ROOT: /opt/buildkit/build/drupal-clean/web
 - CMS_URL: http://drupal-clean.amp.l
 - CMS_DB_DSN: mysql://drupalclea_ybzuc:BaoDsQTs4EJo4yB7@localhost:/drupalcleancms_9r44i?new_link=true
 - CIVI_DB_DSN: mysql://drupalclea_4wr9l:yuaXYepeH6OIb6j5@localhost:/drupalcleancivi_irtdh?new_link=true
 - TEST_DB_DSN: mysql://drupalclea_m87tm:UMIBQhCy9l2cMU5V@localhost:/drupalcleantest_c5gl6?new_link=true
 - ADMIN_USER: admin
 - ADMIN_PASS: Ah0ejAJFXnxN
 - DEMO_USER: demo
 - DEMO_PASS: demo
[[General notes]]
 - You may need to restart httpd.
 - You may need to add the hostname and IP to /etc/hosts or DNS.

```

At this point I log into the new Drupal site at http://drupal-clean.amp.l, I visit CiviCRM, and all appears to be working well.

Back at the command line now, I try to run phpunit:

```
11:15 $ cd /opt/buildkit/build/drupal-clean/web/sites/all/modules/civicrm

11:17 $ env CIVICRM_UF=UnitTests phpunit5 ./tests/phpunit/CRM/AllTests.php
Parsing schema description /opt/buildkit/build/drupal-clean/web/sites/all/modules/civicrm/xml/schema/Schema.xml
Extracting database information
Extracting table information
Installing drupalcleantest_c5gl6 schema
<p>Initialization Error</p><p><pre>Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -24
    [message] => DB Error: connect failed
    [mode] => 16
    [debug_info] =>  [nativecode=mysqli_connect() expects parameter 5 to be integer, string given]
    [type] => DB_Error
    [user_info] =>  [nativecode=mysqli_connect() expects parameter 5 to be integer, string given]
    [to_string] => [db_error: message="DB Error: connect failed" code=-24 mode=callback callback=CRM_Core_Error::handle prefix="" info=" [nativecode=mysqli_connect() expects parameter 5 to be integer, string given]"]
)
</pre></p><p></p><p>Initialization Error</p><p><pre>Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -24
    [message] => DB Error: connect failed
    [mode] => 16
    [debug_info] =>  [nativecode=mysqli_connect() expects parameter 5 to be integer, string given]
    [type] => DB_Error
    [user_info] =>  [nativecode=mysqli_connect() expects parameter 5 to be integer, string given]
    [to_string] => [db_error: message="DB Error: connect failed" code=-24 mode=callback callback=CRM_Core_Error::handle prefix="" info=" [nativecode=mysqli_connect() expects parameter 5 to be integer, string given]"]
)
</pre></p><p></p>

```

**Question:** Am I doing something wrong? Is this a bug in civibuild or elsewhere? How can I get around this?

# Answer
The problem was a missing port specification as evidenced by the `localhost:` with a colon but no port, and evidenced further since port is parameter 5 to mysqli\_connect() as in the error. `amp config` needed re-running and specifying a port.
> 0 votes

---
Tags: civicrm-buildkit, testing, unit-testing, phpunit
---