# Question
Title: Db Upgrade from 4.5.5 to 5.1.2 fails with [Error: Upgrade DB to 4.6.alpha7]
Upgrading CiviCRM 4.5.5 on Wordpress 4.9.6 to CiviCRM 5.1.2...

I tried upgrading database from 4.5.5 to 5.1.2 and got the error below. Any version above 4.6.0 gives the same error (tried them all!). However, upgrading from 4.5.5 to 4.5.8 works, but upgrade from 4.5.8 to 5.1.2 fails with the same error. What happens in 4.6.alpha7 that breaks the upgrade?? How to get past this?

Error: Upgrade DB to 4.6.alpha7

Details are:

ALTER TABLE civicrm\_mailing\_abtest ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID', ADD COLUMN `created_date` datetime COMMENT 'When was this item created', ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8\_unicode\_ci DEFAULT NULL, ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8\_unicode\_ci DEFAULT NULL, ADD CONSTRAINT FK\_civicrm\_mailing\_abtest\_created\_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL \[nativecode=1060 \** Duplicate column name 'created\_id'\]

Any help much appreciated. Here is the error log:

```
May 24 11:47:23  [info] $CRM_Queue_Page_AJAX_runNext_error = PEAR_Exception: "DB Error: unknown error"
 * ERROR TYPE: DB_Error
 * ERROR CODE: -1
 * ERROR MESSAGE: DB Error: unknown error
 * ERROR MODE: 16
 * ERROR USERINFO: ALTER TABLE civicrm_mailing_abtest
  ADD COLUMN `created_id` int unsigned    COMMENT 'FK to Contact ID',
  ADD COLUMN `created_date` datetime    COMMENT 'When was this item created',
  ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
  ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
  ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1060 ** Duplicate column name 'created_id']
 * ERROR DEBUGINFO: ALTER TABLE civicrm_mailing_abtest
  ADD COLUMN `created_id` int unsigned    COMMENT 'FK to Contact ID',
  ADD COLUMN `created_date` datetime    COMMENT 'When was this item created',
  ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
  ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
  ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1060 ** Duplicate column name 'created_id']
#0 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#1 [path to content]/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#2 [path to content]/wp-content/plugins/civicrm/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: unknown error", -1, 16, (Array:2), "ALTER TABLE civicrm_mailing_abtest\n  ADD COLUMN `created_id` int unsigned   ...")
#3 [path to content]/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-1, 16, (Array:2), "ALTER TABLE civicrm_mailing_abtest\n  ADD COLUMN `created_id` int unsigned   ...")
#4 [path to content]/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -1, NULL, NULL, "ALTER TABLE civicrm_mailing_abtest\n  ADD COLUMN `created_id` int unsigned   ...", "DB_Error", TRUE)
#5 [path to content]/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(899): DB_common->raiseError(-1, NULL, NULL, NULL, "1060 ** Duplicate column name 'created_id'")
#6 [path to content]/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()
#7 [path to content]/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("ALTER TABLE civicrm_mailing_abtest\n  ADD COLUMN `created_id` int unsigned   ...")
#8 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Utils/File.php(303): DB_common->query("ALTER TABLE civicrm_mailing_abtest\n  ADD COLUMN `created_id` int unsigned   ...")
#9 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Form.php(197): CRM_Utils_File::sourceSQLFile("mysql://[database access stuff]?new_link...", "-- location_type_id should have default NULL, not invalid id 0\nALTER TABLE c...", NULL, TRUE)
#10 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Form.php(394): CRM_Upgrade_Form->source("-- location_type_id should have default NULL, not invalid id 0\nALTER TABLE c...", TRUE)
#11 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Form.php(428): CRM_Upgrade_Form->processLocales("[path to content]/wp-content/plugins...", "4.6.alpha7")
#12 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Form.php(686): CRM_Upgrade_Form->processSQL("4.6.alpha7")
#13 [internal function](): CRM_Upgrade_Form::doIncrementalUpgradeStep(Object(CRM_Queue_TaskContext), "4.6.alpha7", "4.5.5", "4.6.0", "/tmp/civicrm-post-upgrade3KkVLN")
#14 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Queue/Task.php(88): call_user_func_array((Array:2), (Array:5))
#15 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Queue/Runner.php(213): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
#16 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Queue/Page/AJAX.php(52): CRM_Queue_Runner->runNext(TRUE)
#17 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Queue/ErrorPolicy.php(106): CRM_Queue_Page_AJAX::{closure}()
#18 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Queue/Page/AJAX.php(54): CRM_Queue_ErrorPolicy->call(Object(Closure))
#19 [internal function](): CRM_Queue_Page_AJAX::runNext()
#20 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(278): call_user_func((Array:2))
#21 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:13))
#22 [path to content]/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:5))
#23 [path to content]/wp-content/plugins/civicrm/civicrm.php(1133): CRM_Core_Invoke::invoke((Array:5))
#24 [internal function](): CiviCRM_For_WordPress->invoke("")
#25 [path to content]/wp-includes/class-wp-hook.php(286): call_user_func_array((Array:2), (Array:1))
#26 [path to content]/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters("", (Array:1))
#27 [path to content]/wp-includes/plugin.php(453): WP_Hook->do_action((Array:1))
#28 [path to content]/wp-admin/admin.php(224): do_action("toplevel_page_CiviCRM")
#29 {main}

```

# Answer
When I do upgrades from older versions, I do it in small steps. In this case I would do:

4.5.5 --\> 4.5.8 If that succeeds I would then do:

4.5.8 --\> 4.6.36

If that succeeds I'd go from:

4.6.36 --\>5.1.2

If it fails, I would then look at the Altering the table that caused the error before running the upgrade script. I've found that not all fixes to the update scripts make it to the next version.
> 2 votes

# Answer
The error is `Duplicate column name 'created_id'` so your `civicrm_mailing_abtest` table already has that column. Trying to rerun the upgrade and will just attempt to do the same thing unsuccessfully. It sounds like you have tried multiple upgrades but they will all fail to get past this step. When you upgrade, Civi applies all the upgrade steps from the current version to the target one, so if you fail getting to 4.6.0, attempts to go further won't work.

The failure to focus on is the first one. Try looking at the log under `files/civicrm/ConfigAndLog`. You should see messages from the upgrade steps followed by the error.

You have two basic choices: either restore the database as it was prior to your upgrades and try again, or try to figure out went wrong and correct it. The first option is safer and easier, but no guarantee that it will work since there may already be a mismatch between your database and the state the upgrade steps expect to encounter. You can compare the log messages with the files in `CRM/Upgrade/Incremental` and look at your database to see which step it initially failed at. From there you can complete the remaining steps manually and update the version in the database so that later upgrades work. See After a failed upgrade, is updating the table structure enough? for more details.

If that seems daunting, try https://civicrm.org/partners-contributors
> 2 votes

# Answer
In fact, the table `civicrm_mailing_abtest` shouldn't even exists in the CiviCRM 4.5.5 database.

When doing the upgrade the first time, CiviCRM has created it (introduced in 4.6.alpha1 and then updated in 4.6.alpha7).

Unfortunately, your upgrade has crashed (my guess is : because of a timeout) and a mysql backup doesn't contains any queries to delete the newly created tables so you have to clean your database (delete all the tables) prior restoring the data if you really want to have the same database as before.

However, you should ensure that your backup contains all the structure of the tables - i.e. queries like "CREATE TABLE ...".

When looking at the source, it seems that only 2 tables are created between 4.5.5 and 4.6.alpha7 : `civicrm_mailing_abtest` and `civicrm_recurring_entity`. So you might be able to simply delete those 2 tables and restart from there.
> 0 votes

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


# Question
Title: Wordpress profile will allow view but not edit when logged in
Won't work on my system (4.7.10) and replicated on Wordpress sandbox.

I've created a very simple profile: last name & first name. All fields are expose publicly, searchable, results column etc Profile ticked "include profile edit links in search results?

Using link from profile "use - listings mode" while logged in as admin. Ie "http://wpmaster.demo.civicrm.org/civicrm/?page=CiviCRM&q=civicrm/profile&gid=14&reset=1"

Search works fine but listing only has view option - no edit

Same when using \[civicrm component="profile" gid="68" mode="search" hijack="0"\]

Am I missing something? Same setup works fine on Drupal site

# Answer
> 1 votes
Looks like a WordPress/Civi permissions issue - have you checked at /wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin%2Faccess%2Fwp-permissions&reset=1

# Answer
> 0 votes
I thought it might help get towards an answer if we get some screenshots in here (which I can't do in Comment)

Having tweaked the Name and Address Profile on wp demo site to do the right things, and if i search at http://wpmaster.demo.civicrm.org/civicrm/?page=CiviCRM&q=civicrm/profile&gid=1&reset=1 for 'g' i get the above, and I get a View link but no Edit link.

Pls paste equivalent for drupal

# Answer
> 0 votes
Thanks for looking Pete Here it is working fine under Drupal

---
Tags: wordpress, profile
---


# Question
Title: Unexpected Error when registering for an Event via Webform
Running Civi 4.7.27 / Drupal 7.59

I have developped a rather complex Webform to enable the registration of several participants, with conditionals and associated Contributions, to an Event (I already have had several of this kind without any problem).

But with this one, when I complete the registration, I get an "Unexpected Error".

Then, if I come back to the form (via the browser back arrow), and re-register, everything runs OK.

Of course, I Can't put this webform in production without solving this : any help is welcome.

# Answer
> 1 votes
I think I found the cause : I forgot to fill the "Fee" tab of the Event Form.

Everything is running OK now

---
Tags: webform-civicrm
---


title: Contact image not displaying

text:
# Question
Title: Contact image not displaying
I updated civi to version 4.7.25 (from 4.7.8) and now instead of seeing the contact image there's the text "custom" with a link that I can't open

It should display the profile image coming from the civi db (civicrm\_contact.image\_URL)

the "custom" link is https://\[website\]/civicrm/file?reset=1&filename=custom&mime-type=image/

Any ideas?

# Answer
I am encountering the same problem, but only with images uploaded via Webform; if I edit the profile, delete the image reference, and re-upload the file, it displays as expected.

The reason is that Webform CiviCRM inserts the image\_URL value in the database as the path to the webform upload, e.g. `/sites/default/files/webform/NNNN.ext`. The CiviCRM handler (CRM/Utils/File.php) expects CiviCRM-style image URLs of the form `/civicrm/contact/imagefile?photo=NNNN.ext`, and so mangles the path twice, once on reading it and then when it runs getFileURL on it.

Thus, anything dependent on $imageURL will break for images uploaded through Webform or other external mechanisms.

The issue is reported on Webform CiviCRM Integration as *Contact Image Upload field integration not working with 4.7*, first reported by goron on 29 November 2017, with no activity since. I did not find any corresponding issues filed in JIRA. I am using a hacky workaround but it is specific to our particular environment and installation.
> 2 votes

# Answer
This is still a problem as of CiviCRM v4.7.30. As it currently stands based on the observed behavior, CiviCRM cannot handle relative-URLs for contact images. The "image\_URL" property of the CiviCRM Contact data structure seems to expect a certain URL base. It seems that you can't use external or internal-non-CiviCRM urls.

Unless this changes or unless Webforms CiviCRM integration changes its behavior (I don't use the integration so I can't confirm if this has happened), this will probably remain broken.
> 1 votes

---
Tags: contact-image
---


# Question
Title: Issue with adding price field options to admin price field
CiviCRM 5.1.2, Drupal 7.59

We're attempting to add a price field option to an admin-only price field, and we're getting this error: "You must choose "Admin" visibility..." As you can see here (https://www.screencast.com/t/9n3VBhi9FTY ), I've clearly chosen admin. I also tried choosing public on the off chance the logic got reversed. (FWIW we've not been able to replicate this on the demo site; there are no error messages recorded in the log and no backtrace error was generated when I turned it on and tried again.) The client was previously on 4.6.x; has any logic around price sets changed substantively?

Thanks in advance.

# Answer
> 1 votes
Can you try after upgrading CiviCRM to 5.2.1? It might be possible it was an issue with previous version of CiviCRM.

HTH

Pradeep

# Answer
> 1 votes
This actually turned out to be an issue that occurred when the price set was copied - the visibility settings do not appear to have come over correctly in the copying process. We need to do more testing on this from our end but for those who are copying price sets, you might want to confirm that your visibility settings remain as expected. Thanks to Pradeep for responding.

---
Tags: civievent
---


# Question
Title: Charts using data from CiviCRM to show on Drupal website
Is it possible for a chart to be created from data on the CiviCRM side and show on the website (drupal) portion?

For example, we would like to have a graph that live updates how much of our grant has been paid out and to what category.

# Answer
How about pulling your grant data into a Drupal View and then using Charts and Google Charts module to display them?
> 5 votes

# Answer
There is also Civisualize, a data visiualisation extension: https://civicrm.org/extensions/civisualize-missing-data-visualization-extension

And you could also use external tools for data visualisation, in one project I have worked with Apache Zeppelin as data visualisation: https://zeppelin.apache.org/
> 3 votes

# Answer
Just as an update to how it looks. Using Webform with the Google Charts module.
> 2 votes

---
Tags: drupal, chart
---


title: Customise contribution thank you page

text:
# Question
Title: Customise contribution thank you page
I'm new to CiviCRM, but done a lot of playing around for a new activist network I'm a part of. It's a brilliant tool! We are building our site in wordpress.

Becoming a member of our network is free, and we've created a contribution page to collect a few details from individuals. We'd like to edit the "thank you" page that users are sent to once they have completed the contribution page, so that it's cleaner and easier to read, and (most importantly) doesn't have the information about a membership fee - we're worried this will confuse people, even though it will of course say £0.00, because they are not paying anything.

Any tips on how to edit this page? And apologies if it's glaringly obvious ;)

# Answer
> 2 votes
You don't need to use a Contribution page to collect a few details. You can do this via a Profile so it may make more sense to direct contacts to the Profile if they are not donating at the same time

# Answer
> 2 votes
The easiest answer to the question as asked is Fuzion's Front End Page Options CiviCRM extension. It allows you to specify an alternate "thank you" page, which you can create freely in WordPress.

A programmer could also write an extension that modifies the thank-you page, but this option requires knowledge of PHP. However, this option allows you to pull in variables from the person's contact/contribution records.

# Answer
> 1 votes
Agreed with Pete that if you're not collecting payment, a profile is preferable to a contribution page. If you need more flexibility than profiles allow, also consider using Caldera Forms with CiviCRM integration. Drupal and Backdrop CMS users with similar needs should use Webform with CiviCRM integration.

---
Tags: wordpress, civicontribute
---


# Question
Title: Which table is used for hook_civicrm_triggerInfo?
I have a rebuild trigger action that is failing. It is trying to create a trigger on civicrm\_contributiion\_recur. Clearly it has 2 i's and shouldn't. There is or was a trigger on the table without the extra i, so I figure it got stored in the db incorrectly. I went off in search of just where that stuff is stored but alas haven't found where.

So when you use hook\_civicrm\_triggerInfo to create a custom trigger where is that info stored?

Or when civi does an index rebuild how does it collect the list of tables and the bodies of the triggers? It needs to do this so it can combine any triggers civi core has with any custom triggers an extension or customization has added.

# Answer
Triggers are stored in the `information_schema`, a virtual database provided by MySQL. This StackOverflow answer gives a pretty good overview.
> 1 votes

---
Tags: hooks
---


title: Wordpress Multisite Installation Error

text:
# Question
Title: Wordpress Multisite Installation Error
I have a Wordpress multisite that I have civicrm installed on. I did an upgrade to the new version and the database shows that it is the new version. Problem is that the civi dashboard thinks it has not been upgraded and shows an error.

# Answer
> 2 votes
I've seen this happen when there's a permission issue on the `version-info-cache.json` file that prevents the upgrader from properly deleting it. The file can be found in your CiviCRM "Temporary Files Directory".

If you're not sure where to find your Temporary Files Directory, you can check at **Administer menu » System Settings » Directories**. If there's a token (e.g. `[civicrm.files]/upload`), you can see the value of the token by pressing the "help" icon (see screenshot below).

Try deleting `version-info-cache.json` manually (e.g. via FTP or CPanel File Manager). Then visit the Civi System Status Page (**Administer menu » Administration Console » System Status**) and the issue should clear up.

This file is also auto-deleted every three days - so if this seems like a lot, simply ignore it!

---
Tags: wordpress, multisite
---


title: Multi-part Join Form

text:
# Question
Title: Multi-part Join Form
I want to collect a lot of information from members, but I don't want it to have 30 fields on the same page, it'll be too intimidating. I want to break it up across multiple pages. "Join - Page 1 of 3" etc

How do I do that?

I know how to link one form to another, so that upon completing a form the user is directed to the next form. But how do I get CiviCRM to recognize that they are the same person? So the entered information goes to the same record?

I don't want them to have to create a login on the site. I'm using Wordpress.

# Answer
I would suggest you try out Caldera Forms CiviCRM WordPress plugin: https://github.com/mecachisenros/caldera-forms-civicrm

You need to firstly install the Caldera Forms plug-in for WordPress and then install the Caldera Forms CiviCRM plug-in (also for WordPress). Caldera Forms out of the box, allows for the creation of multiple pages for a single form. The Caldera Forms CiviCRM plug-in, adds the integration with Caldera Forms and CiviCRM. I currently have both plug-ins installed in our WordPress site and I'm busy exploring the creating of a contact capture form with custom CiviCRM fields. The form is pretty large, so I am busy splitting it into multiple pages. I have not tested any form submission yet, but hope to complete the form and test it within the next week.
> 3 votes

# Answer
I think the best solution would be to create a single-page form but use Javascript to format the fields like a Wizard.
> 2 votes

# Answer
Take a look at gravity forms. You can do mulitpage. https://www.gravityforms.com/

There is also a CiviCRM/Gravity Forms Integration Extension http://shop.civivip.com/civi-plugins/gravity-forms-integration/ I have not used the integration so I cannot answer for sure that it will record all the answers in their contact profile.

I use it on our site and love it. https://radiusinternational.org/student-application/

I have also tested Caldera Forms about 6 months ago then went with Gravity. I highly recommend Gravity Forms.
> 2 votes

---
Tags: wordpress, profile
---


# Question
Title: Civix: Install error: API error: DB Error: already exists
According documentation I created a skeleton module with civix and answered yes to install it. It then gives an error response as in the Title. Afterwards is listed active in the extensions page.

This is on 4.6.8 recently upgraded from 4.6.4. Since the module seems active the error messsage is apparently not related to the installed module. When under Drupal I use the tool drush I got this more extensive error response even before creating/installing the skeleton module:

```
exception 'Exception' with message 'API error: DB Error: already exists' in /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php:453              [error]
Stack trace:
#0 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(234): CRM_Core_ManagedEntities->onApiError('RelationshipTyp...', 'create', Array, Array)
#1 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(179): CRM_Core_ManagedEntities->insertNewEntity(Array)
#2 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(141): CRM_Core_ManagedEntities->reconcileEnabledModule(Object(CRM_Core_Module), Array)
#3 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(122): CRM_Core_ManagedEntities->reconcileEnabledModules()
#4 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Invoke.php(403): CRM_Core_ManagedEntities->reconcile()
#5 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/drupal/civicrm.module(1407): CRM_Core_Invoke::rebuildMenuAndCaches(true)
#6 [internal function]: civicrm_modules_enabled(Array)
#7 /var/www/civicrm/htdocs/drupal/includes/module.inc(895): call_user_func_array('civicrm_modules...', Array)
#8 /var/www/civicrm/htdocs/drupal/includes/module.inc(499): module_invoke_all('modules_enabled', Array)
#9 /home/c2/.composer/vendor/drush/drush/commands/core/drupal/environment_7.inc(143): module_enable(Array)
#10 /home/c2/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1120): drush_module_enable(Array)
#11 [internal function]: drush_pm_enable('help')
#12 /home/c2/.composer/vendor/drush/drush/includes/command.inc(368): call_user_func_array('drush_pm_enable', Array)
#13 /home/c2/.composer/vendor/drush/drush/includes/command.inc(219): _drush_invoke_hooks(Array, Array)
#14 [internal function]: drush_command('help')
#15 /home/c2/.composer/vendor/drush/drush/includes/command.inc(187): call_user_func_array('drush_command', Array)
#16 /home/c2/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
#17 /home/c2/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#18 /home/c2/.composer/vendor/drush/drush/drush.php(11): drush_main()
#19 {main}

```

When I look in the related ConfigAndLog I see:

```
Sep 08 14:14:08  [info] $backTrace = #0 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Error.php(897): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#3 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
#4 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-5, 16, (Array:2), "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
#5 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -5, NULL, NULL, "INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...", "DB_Error", TRUE)
#6 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/mysqli.php(929): DB_common->raiseError(-5, NULL, NULL, NULL, "1062 ** Duplicate entry 'Benefits Specialist is' for key 'UI_name_a_b'")
#7 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#8 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
#9 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(2442): DB_common->query("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
#10 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/packages/DB/DataObject.php(1060): DB_DataObject->_query("INSERT INTO civicrm_relationship_type (name_a_b , label_a_b , name_b_a , labe...")
#11 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/DAO.php(450): DB_DataObject->insert()
#12 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Contact/BAO/RelationshipType.php(126): CRM_Core_DAO->save()
#13 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/v3/RelationshipType.php(62): CRM_Contact_BAO_RelationshipType::add((Array:11), (Array:1))
#14 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_relationship_type_create((Array:11))
#15 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Kernel.php(96): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
#16 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel->run("RelationshipType", "create", (Array:10), NULL)
#17 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(232): civicrm_api("RelationshipType", "create", (Array:10))
#18 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(179): CRM_Core_ManagedEntities->insertNewEntity((Array:6))
#19 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(141): CRM_Core_ManagedEntities->reconcileEnabledModule(Object(CRM_Core_Module), (Array:4))
#20 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/ManagedEntities.php(122): CRM_Core_ManagedEntities->reconcileEnabledModules()
#21 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Core/Invoke.php(403): CRM_Core_ManagedEntities->reconcile()
#22 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/CRM/Extension/Manager.php(246): CRM_Core_Invoke::rebuildMenuAndCaches(TRUE)
#23 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/v3/Extension.php(56): CRM_Extension_Manager->install((Array:1))
#24 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_extension_install((Array:3))
#25 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/Civi/API/Kernel.php(96): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9))
#26 /var/www/civicrm/htdocs/drupal/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel->run("Extension", "install", (Array:3), NULL)
#27 /home/c2/bin/civix.php/src/CRM/ClientBundle/class.api.php(228): civicrm_api("Extension", "install", (Array:3))
#28 /home/c2/bin/civix.php/src/CRM/ClientBundle/class.api.php(141): civicrm_api3->call("Extension", "install", (Array:1))
#29 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(101): civicrm_api3->__call("install", (Array:1))
#30 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(101): civicrm_api3->install((Array:1))
#31 /home/c2/bin/civix.php/src/CRM/CivixBundle/Command/InitCommand.php(80): CRM\CivixBundle\Command\InitCommand->tryEnable(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), "ipdp.relperms")
#32 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(238): CRM\CivixBundle\Command\InitCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(192): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(78): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /home/c2/bin/civix.php/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(105): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 /home/c2/bin/civix.php/civix(22): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#37 {main}

Sep 08 14:14:08  [info] $ManagedEntities_failed = Array
(
    [entity] => RelationshipType
    [action] => create
    [params] => Array
        (
            [version] => 3
            [name_a_b] => Benefits Specialist is
            [name_b_a] => Benefits Specialist
            [label_a_b] => Benefits Specialist is
            [label_b_a] => Benefits Specialist
            [description] => Benefits Specialist
            [contact_type_a] => Individual
            [contact_type_b] => Individual
            [contact_sub_type_a] =>
            [contact_sub_type_b] =>
        )

    [result] => Array
        (
            [error_code] => already exists
            [tip] => add debug=1 to your API call to have more info about the error
            [is_error] => 1
            [error_message] => DB Error: already exists
        )

)

```

What could be the cause and how to fix this?

# Answer
After posting my comment, I did a little bit of digging into what the `CRM_Core_ManagedEntities::reconcile` function does. It says:

```
* Identify any enabled/disabled modules. Add new entities, update
* existing entities, and remove orphaned (stale) entities

```

So it would seem that it's confused because "Benefits Specialist Is" is a relationship associated with CiviCase, but perhaps you have it enabled with CiviCase disabled or vice versa. Try enabling/disabling that relationship to match whether you use CiviCase and see if the error persists.
> 2 votes

# Answer
Same happened after upgrade from 4.6 to 5.1 and I had visit the Case Types config page, then remove the Case Roles mentioned in ConfigAndLog, saved the Case Type, then added them back in again.
> 0 votes

---
Tags: database, issues, civix
---


# Question
Title: How to automatically create mailings from an RSS feed
phpList has an RSS Feed extension which enables it to send out mailings each time a new feed entry is found. Does anything like this already exist in CiviCRM, or would it be difficult to piece together something that would accomplish this?

# Answer
Afaik there is nothing that does this out of the box. We are however working on two extensions that could accomplish this:

Newsstore \- grabs content from sources like RSS and provides them as "items" in CiviCRM via the API

Newsstoremailer \- uses those items to send out mailings automatically

Both extensions are still under development and even when finished you will probably need some additional custom code like this to make it work.

However, it is probably worth to take look at them as the topic is rather complex and you could avoid doing duplicate work. If you want to discuss details or a cooperation you may want to get in touch with Rich Lott from Artfulrobot who currently has the lead in the development.
> 2 votes

---
Tags: civimail
---


title: Foreign Key issues when restoring db

text:
# Question
Title: Foreign Key issues when restoring db
When we export our db and try restoring to another server we get the foreign key issue below so cant progress. Is it safe to Disable foreign key checks when importing into the new server?

(we tried to fix the indexes through the api even)

# ERROR:

SQL query:

```
ALTER TABLE `civicrm_activity`
 ADD CONSTRAINT `FK_civicrm_activity_campaign_id` FOREIGN KEY
 (`campaign_id`) REFERENCES `civicrm_campaign` (`id`) ON DELETE SET NULL,
 ADD CONSTRAINT `FK_civicrm_activity_original_id` FOREIGN KEY (`original_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE CASCADE,
 ADD CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`)
 REFERENCES `civicrm_activity` (`id`) ON DELETE CASCADE,
 ADD CONSTRAINT `FK_civicrm_activity_phone_id` FOREIGN KEY (`phone_id`) REFERENCES `civicrm_phone` (`id`) ON DELETE SET NULL,
 ADD CONSTRAINT `FK_civicrm_activity_relationship_id` FOREIGN KEY
 (`relationship_id`) REFERENCES `civicrm_relationship` (`id`) ON DELETE SET NULL

```

MySQL said: Documentation

> 1452 - Cannot add or update a child row: a foreign key constraint fails (`chercivi_life1`.`#sql-622_4c0a`, CONSTRAINT `FK_civicrm_activity_campaign_id` FOREIGN KEY (`campaign_id`) REFERENCES `civicrm_campaign` (`id`) ON DELETE SET NULL)

# Answer
I think there might me some orphan data in your civicrm\_activity table. Can you run the below query to check if you get any result?

```
SELECT * FROM `civicrm_activity` ca
LEFT JOIN civicrm_campaign cc ON cc.id = ca.campaign_id
WHERE ca.campaign_id IS NOT NULL AND cc.id IS NULL;

```

If you get result then probably you will need to delete this activity or make campaign\_id to NULL for all this records.

> Note: Foreign key is important in CiviCRM, Many foreign keys are set to ON CASCADE DELETE or SET NULL. So its possible you might end up more orphan data in your database if you disable them which may have problem while upgrading CiviCRM in future.

You can use below query to either update the civicrm\_activity.campaign\_id or delete campaign activities

```
UPDATE `civicrm_activity` ca
LEFT JOIN civicrm_campaign cc ON cc.id = ca.campaign_id
SET ca.campaign_id = NULL
WHERE ca.campaign_id IS NOT NULL AND cc.id IS NULL;

OR

DELETE ca.* FROM `civicrm_activity` ca
LEFT JOIN civicrm_campaign cc ON cc.id = ca.campaign_id
WHERE ca.campaign_id IS NOT NULL AND cc.id IS NULL;

```

> Note: Backup your database before you execute above sql.

HTH

Pradeep
> 3 votes

# Answer
I agree. It's safe to disable them temporarily but if you get errors when trying to enable them there is data missing issue. You might want to run data check on your live data to be sure it's not getting DB error. And how are you exporting? You should be using mysqldump and taking out the definer clauses.
> 0 votes

---
Tags: mysql
---


title: DB Error - Events Dashboard

text:
# Question
Title: DB Error - Events Dashboard
I'm working on a new install.

The Events/Dashboard menu choice generates a screen with the following error:

Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred. DB Error: unknown error Return to home page.

There's nothing in the DB log.

I tried the Settings/Cleanup Caches and Update Paths/ panel doing both Cleanup Caches and Reset Paths, but to no avail.

I'm stumped.

# Answer
> 3 votes
This was a core bug and was fixed at 5.1.0. You can either apply the patch from here or Upgrade CiviCRM to 5.2.2.

HTH

Pradeep

---
Tags: civievent, error-page
---


title: Creating a Contact Form in CiviCRM

text:
# Question
Title: Creating a Contact Form in CiviCRM
(I use CiviCRM with Wordpress, so I can't use the Drupal/CiviCRM contact form integration.)

I am trying to create contact forms for my website. I feel like using Profiles is the best way to do this, but I can't figure out how to have a "message" field where the user can write their message to submit. I can get the name, email fields into the profile fine, but there seems to be no way to give them a space to write an enquiry. "Notes" is the closest thing, but their old notes would be overwritten so it would not be ideal.

Is there some way to include an enquiry form with a Profile?

# Answer
> 5 votes
I'm going to give a bit more insights, you are on the right path.

The final step is to add, as you said, the default Contact notes Civi has for each contact, the notes field is a **Multiple record set field**, which as it's own name says allows to create multiple data entries for the same set of fields, ie. you can have 10 notes entries, so every time a user submits the form it will create a new note instead of updating a existing one. Please note that the Multiple record field is only available for the Contacts entity, also make sure that the profile is set to update in the settings accordion.

If you don't want to use the existing Notes that Civi provides then you could create a new set of custom fields, navigating to **Administer - Customize data and screens - Custom fields - Add set of custom fields** give it the desired name (for example Enquiry), *Used for* -\> select **Contacts** once done a checkbox will appear saying something like ***Does this custom set allow multiple records*** make sure you check it. You could display it as a **Tab** and add a custom field like Subject (Alphanumeric - Text) and a second field Message/Enquiry (Note - Text/Rich text). Once finished you can add the created custom fields to your profile. If I didn't explained myself you can always have a look at CiviCRM documentation or leave a comment here.

PS: if you go the custom field path, you will also have to give the **Access all custom data** permission to anonymous users if applies, **User and Permission - Permission (Access control) - Wordpress Access Control**

# Answer
> 3 votes
As Prem Patel said, you may add a custom field assigned to contacts and use this in your profile. If that's no good, try utilizing the notes field on contacts.

# Answer
> 3 votes
In WordPress I use Caldera Forms with CiviCRM integration to create an Activity. This maps better to the data - you want their message to be part of the act of contacting you, not part of their actual contact.

Additionally:

* You get lots of useful fields (like the timestamp) for free.
* If you have multiple contact forms for different purposes, you can easily distinguish between them with different activity types (or a custom field if you prefer).

# Answer
> 0 votes
I've done both options that Andrei mentions above, the email out to both client and administrators always shows the 1st note value in the multiple record set and not the message/note/inquiry that was submitted by the customer.

---
Tags: wordpress, profile
---


# Question
Title: Latest 'Note' field is not being used in the "Profiles - Admin Notification" email template
Was wondering if anyone else has seen this problem and found a fix. I was going to test on the Demo site, http://dmaster.demo.civicrm.org, but I figured I wouldn't be able to receive the email to see if the problem exists there since I'm not an Admin.

The situation is that I'm leveraging the existing ***Note*** field for Contacts in a Contact Us profile used on our WordPress Frontend. Basically option #1 indicated in the first paragraph of the answer for the following question:

Creating a Contact Form in CiviCRM

When the Admin receives the email from the Contact Us profile submission it seems to always parse in the first ***Note*** for the contact and not the last ***Note*** (which would have been what was submitted at the time).

# Answer
Rather than using "Notes", consider creating an activity instead - and instead of using Profiles, use Caldera Forms with CiviCRM integration to create the Activity.

There are several advantages, including those I mention here, but also that you won't get the wrong "note", or pollute your notes data with information that's not really a note.
> 2 votes

# Answer
I gather this is tricky in WP as there is not an easy solution that triggers the creation of an Activity, which imo is the logical way to do this in civicrm.

In this answer they talk about CiviVIP and their \[Gravity Forms integration\]\[3\] but of course there is a cost for that plugin.
> 0 votes

---
Tags: profile, message-templates, admin
---


# Question
Title: Can no longer modifiying priceset amounts in hooks in 5.1.2
I'm looking for help on adjusting a priceset amount in a hook at the end of a membership signup. Until now under 4.7 for reasons of multi-level priceset complexity I've been adjusting priceset amounts via the hook\_civicrm\_validateForm by adjusting the values in the $form object. This has been working fine, but this is now longing working in 5.1.2. I realise that strictly speaking I shouldn't modify the $form in the validateForm hook. "The hook is intended for validation rather than altering form values." However I can't see anywhere else to change the amounts. I have two questions, i) Can anyone explain the difference in behaivour between 4.7 and 5.1.2? ii) is there a better place or method to adjust the priceset amount?

# Answer
You can use Build Amount hook to alter the price. If you want to trigger the change on form submit than you can use $form-\>\_flagSubmitted. This is set to true when form is submitted. You can also use buildform or post process hook. But validateForm is a bad option.

```
function xxx_civicrm_buildAmount($pageType, &$form, &$amount) {
  if (get_class($form) == 'CRM_Event_Form_Registration_Register' && $form->_flagSubmitted) {
    foreach ($amount as $key =$value) {
      foreach ($value['options'] as $pid =$value) {
        $amount[$key]['options'][$pid]['amount'] = $value['amount'] - ($value['amount'] * 0.1);
      }
    }
  }
}

```

HTH

Pradeep
> 3 votes

---
Tags: price-sets
---


# Question
Title: Can't create a new event template from an existing event template
in Civi 4.5.4 I'm trying to create a new event template from an existing template. When I do that, I start at this screen: /civicrm/event/add?action=add&is\_template=1&reset=1

When I select an existing template, functionality is expected - the page is populated with the details from the existing template. The page's URL stays the same.

However, when I click continue, I suddenly get transferred to an event creation page. The URL changes to: /civicrm/event/manage/location?action=update&reset=1&id=128 (ID being the eventID)

A new event (of ID 128) has been created and there's no sign of a new event template.

Is this a bug that's been fixed somewhere that I haven't been able to find, or am I missing something here?

Thanks for your help!

# Answer
> 1 votes
I dont think cloning an event template was planned as a feature. I think event templates were meant to be used for creating new events.

So the above behavior is probably doing what was designed.

# Answer
> 1 votes
I just had a look at the demo site http://wpmaster.demo.civicrm.org (CiviCRM 5.4.alpha1)and tried it there and it looks like it was a bug that is now fixed so all you is upgrade to CiviCRM 4.7.31 or later).

See https://issues.civicrm.org/jira/browse/CRM-21743 for details of the bug/fix.

---
Tags: civievent, templates
---


# Question
Title: Recommended cron email sending rate for Mosaico mailings?
Various reports indicate that Mosaico can fail to send large mailings based on memory and cron rates for sending.

How might one calculate the maximum/most effective mailing rate considering available memory and php memory limit settings so as not to inadvertently have a failed mailing.

# Answer
> 1 votes
What I have experienced is that if a larger mailing fails nothing shows as delivered. It never starts. To address this I throttle the number of mailings sent on each cron run. The number can be effected by a few things such as size of the mailing, available memory, PHP memory limit, etc. If you host will allow it I would increase the PHP memory limit first. Then work on a reasonable amount of messages sent per batch.

In most cases I increase the frequency of the cron runs. For Example:

With a mailing that has 1000 recipients and we throttle the mailing to 250 per run then set the cron job to run every 5 minutes we can get the job done in 20 minutes.

Most of the Mosaico mailing we are doing are larger newsletters that are not time critical so sending multiple smaller batches works fine and insures delivery.

Hope this helps

---
Tags: civimail, mosaico
---


# Question
Title: How can I sync the Drupal User Profile image and the CiviCRM contact image?
I'm trying to find a way to automatically update the CiviCRM contact image when a user updates their Drupal profile image. I'm specifically looking for Drupal8.5/Civi4.7 but I'll take anything that can properly update Civi4.7 at this point, regardless of Drupal version. It seems that the Drupal/Civi API functions are almost, but not quite, capable of making this easy, although it may just be a documentation deficiency -- I'm still digging in the code.

I found this discussion on the old Civi forum (circa 2011) which discusses it. https://forum.civicrm.org/index.php%3Ftopic=22405.0.html

There is also some old code in the Civi site which directly updates the database and also doesn't seem to work anymore: https://wiki.civicrm.org/confluence/display/CRMDOC/Adding+pictures+in+civicrm+profile+page

Is there anything as of Civi 4.7.30 which can do this?

If not, can someone point me to some docs/examples that demonstrate how to programmatically add a photo image to a contact in Civi?

# Answer
I think I've figured this out and it seems to work reliably in D8.5.4/CV4.7.30.

The basic approach is to:

1. Lookup the Civi contact based on the Drupal user id
2. Make a copy of the uploaded account pic (Civi can't share, and requires the file to be in the custom uploads dir)
3. Update the image\_URL of the Civi contact using the Civi v3 api

You MUST use the image\_URL value expected by the Civi code, which is specific to its function. It looks like this...

`http://www.mydrupalsite.com/civicrm/contact/imagefile?photo=FILENAME.jpg`

...and the file must be in the CiviCRM custom uploads folder. I see no alternatives to this in the code and the docs are completely silent on it. And, yes, I'm aware that this is a FULLY QUALIFIED URL being stored in the database. Whoever chose this technique was either highly constrained by legacy code or smoking crack. I've tried relative URLs and they don't seem to work.

I've created a Github gist here that demonstrates the approach (use at your own risk):

https://gist.github.com/jptillman/ba3f29fd82cc83f3f1de0d807b50c843

In my site using this code, removing the Drupal image also removes the Civi image from the Contact record, but I'm fairly sure that Civi isn't cleaning up, so this will leave orphaned files behind in the custom uploads folder. Probably wouldn't be too hard to engineer a delete of the file somehow.

NOTE: This code will overwrite any existing picture in the Civi record.
> 1 votes

# Answer
I am not sure how to sync drupal profile image with CiviCRM contact image through UI. But you can add module and invoke hook to update the contact image.

Here is the snippet how to add image url to contact

```
$params = [
  'contact_id' => 2,
  'image_URL' => [
    'name' => '/var/www/html/drupal/sites/default/files/civicrm/custom/Screenshot_from_2018_06_19_15_46_08_1877c5451ed2e68a12816071e0006fef.png',
    'type' => 'image/png',
  ],
];
CRM_Contact_BAO_Contact::processImageParams($params);
civicrm_api3('Contact', 'create', $params);

```

HTH

Pradeep
> 4 votes

---
Tags: drupal, contacts, drupal-8, contact-image
---


# Question
Title: Import exceeding max. number of processes on host
Getting a 500 error on importing CSV content. Consulted with web host, who found the cause of the 500 Internal Server Error. When I click on the import more than 30 processes is spawned from my account. The limit on my plan is 30 processes and this causes the error as the limit is exceeded. The processes are:

Code: php admin.php

They advised me to contact Civi or check the import settings in order to lower the number of processes spawned simultaneously. You should configure it to wait for the process to complete and then spawn new ones.

How do I do this?

# Answer
I found the solution to my issue. The php.ini was causing another issue with my site. When I renamed it, I was able to import as expected.
> 3 votes

---
Tags: import, 500
---


# Question
Title: CiviCRM will not recognize valid email address
I am trying to add a new email address for an existing contact. The address is valid. However, the new address will not save and I received this message: **Please enter a valid email address**

The address is: valerie.king@lottery.nh.gov

How can I get the change accepted and saved?

# Answer
The client-side validation in CiviCRM will flag any invisible or space characters which get pasted in along with an email address or URL. The non-printing characters are the trickiest to find, including things like carriage returns and line feeds that seem to get swept up in some copy-paste operations. I encounter this problem relatively frequently, but it is hard to pinpoint the exact combination of platform, browser, and source.

Therefore, if I have an e-mail address or URL which doesn't seem to take even though it appears to be well-formed, I "clear" the characters by pasting someplace else first, like the `To:` field in an e-mail or the URL bar in the browser. This strips out the non-ASCII characters, and I can then re-select the desired text and paste it into CiviCRM as usual.
> 3 votes

---
Tags: contacts, validation
---


# Question
Title: Participant Count and Capturing additional participant information
If I am using a Price Set field with a multiple participant count (Say, Five registrants for a discounted price of $550) will or can I also capture the additional registrant information.

to expound:

We have individual registration options, as well as a group registration option. I was planning on doing \- 1 price field for General registrant (Participant count of 1) \- 1 price field for Student registrant (Participant count of 1) \- 1 price field for Group of Five (Participant count 5)

Do I need to activate the "Register additional participants" option in order to capture the additional participants names or will civi prompt for that info since the participant count is 5 for the Group of Five option.

If I do have to select the "Register additional participant" setting, would the registrant have to both select 4 from the Register Additional Participants drop down as well as select the "group of 5" option? if this is the case, should the group of 5 participant count really be 1 instead of 5?

Thanks

# Answer
Yes - typically you would activate "register additional participants" to capture the additional names. The participant count being 5 will NOT trigger this. That workflow is preferred when someone is, say, buying a table of 10 for a fundraiser gala but doesn't know who will be attending. And yes - the participant count should be "1" in this case.
> 1 votes

# Answer
It sort of depends on what counts as 'additional information'. For example you could have a Profile that has (Participant-based) fields for the names of Persons 2 - 5, so this does not create Contact records for them, but you do know who they are.
> 0 votes

---
Tags: civievent, price-sets, participants
---


# Question
Title: Organisation membership with Drupal user account
I am running Drupal 7 with Civi, both on the latest version. I would like a user to be able to register to become a member on behalf of an, which creates an account for a user in Drupal core, who can then edit the organisation details.

I've setup the process so far using CiviCRM Profiles and Webforms. Here is my current setup:

* User applies for an account using profiles and Drupal core using logintoboggan to control this part.
* User account is accepted, and an email is set to a webform link

webform: Number of Contacts: 2

1: Organisation

2: Individual (here I have linked the Individuals Current Employer to the Organisation and added them to a group – which is used in a rule to active the user in Drupal’s core, so the user can login after completing registration)

Users are then prompted to pay . This workflow works, mostly anyway.

A couple of questions:

1: Is using the method of adding the Individual to a group which activates the Drupal core user the best method? I feel that this is messy, especially when the organisations membership is due for renewal and if the organisation doesn’t renew how is the individual account deactivated? Is there a better way?

2: How do I allow the user to edit the organisations details?

I have many other thoughts/questions. But this enough… for now :)

Thanks for your help!

SJ

# Answer
One comment is that it would be more common to have Contact 1 set as the Individual (current user) and Contact 2 as the Organisation.

In terms of if an Org does not renew - if you have the Individual 'inheriting' the membership, and hence getting added to a Drupal Role via MemberSync then when the Org fails to renew then the Individual will lose any Roles other than Sync.

An alternative would be to use Drupal Rules based on Membership Status and hence Block the user if their membership Expires but that seems unnecessary imo if you give the Authenticate role no extra permissions.

The Individual needs to be given 'permission' over the Organisation via the Relationship, this will allow the Individual to edit some details via their CiviCRM Dashboard, though I would suggest you give them a Drupal Views block linked to a Webform and let them edit the Org details that way.

HTH
> 3 votes

# Answer
Pete's answer pretty much covers the bases - but make sure to check out the Relationship Permissions as ACLs extension, which should be a big help.
> 0 votes

---
Tags: drupal, civimember
---


# Question
Title: Can't Get CiviCRM BuildKit files From Repository
Unable to get CiviCRM buildkit files.

I am running:

* OS: Linux - Ubuntu 18.04 bionic
* WebServer: Apache/2.4.29 (Ubuntu) built: 2018-04-25T11:38:24
* Database MYSQL Ver 14.14 Distrib 5.7.22
* Language: PHP - Version 7.2.5-0ubuntu0.18.04.1
* Language: Node.js - v10.5.0
* VCS: git version 2.17.1

Executed command below as advised at https://docs.civicrm.org/dev/en/latest/tools/buildkit/

```
curl -Ls https://civicrm.org/get-buildkit.sh | bash -s -- --full --dir ~/buildkit

```

Got the results below.

```
root@joe-Meerkat:/home/joe# curl -Ls https://civicrm.org/get-buildkit.sh | bash -s -- --full --dir ~/buildkit
Detected Ubuntu 18.04 LTS.

Task: acl git wget unzip zip mysql-server mysql-client php7.2-cli php7.2-imap php7.2-ldap php7.2-curl php7.2-mysql php7.2-intl php7.2-gd php7.2-dev php7.2-bcmath php7.2-mbstring php7.2-soap php7.2-zip php7.2-xml apache2 libapache2-mod-php7.2 nodejs npm php-pear libmcrypt-dev libreadline-dev

Warning: This system will not support php-mysql extension

Run automated installation? [Y/n] y
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
-
-
-

Hit:9 http://ppa.launchpad.net/system76-dev/stable/ubuntu bionic InRelease

Err:10 http://ppa.launchpad.net/midori/ppa/ubuntu bionic Release
404  Not Found [IP: 91.189.95.83 80]

Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/midori/ppa/ubuntu bionic
Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is
therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
root@joe-Meerkat:/home/joe#

```

Does anyone know the cause of this and what can be done?

joseph.c.mansigian@gmail.com

# Answer
> 2 votes
At that point in the install script, it is attempting to run `sudo apt-get -y install` for a bunch of packages.

It looks like you have added a ppa for midori but that does not have a bionic release yet. You can run `sudo add-apt-repository -r -u ppa:midori/ppa` or find the entry for midori in `/etc/apt/sources.list` or `/etc/apt/sources.list.d` and comment it out and run `sudo apt update`

Once you can get `sudo apt-get -y install` to run cleanly on some (any) package, try again with the `get-buildkit.sh` script.

Note also that bionic comes with php 7.2 which is marked as 'not yet tested' in https://docs.civicrm.org/sysadmin/en/latest/requirements/#php-version so unless you are only interested in the very latest releases and debugging 7.2 issues, you probably want php 7.1 (see eg https://tecadmin.net/install-php-7-on-ubuntu/). However, if you do that you'll need to install the 7.1 version of the php extensions. Look at the php7.1-\* list in the 'do\_system\_artful' function of `get-buildkit.sh`

---
Tags: drupal
---


# Question
Title: Why is there a page in a CiviCRM WordPress install that says "Do not delete this page."
A CiviCRM page is created on the site: my-site-wordpress/CiviCRM where it says: "Do not delete this page." Page content is generated by CiviCRM " what is it for? how should it work? What should appear on this page? I use WordPress 4.9.6 version - CiviCRM is in a subdirectory Thanks

# Answer
> 8 votes
CiviCRM has some public-facing pages that it generates. e.g. event registrations, unsubscribe confirmations etc.

On Wordpress the page you're seeing is the one that's used by CiviCRM for these purposes. So it's not a page you use or link to directly yourself, but it has to exist as far as Wordpress is concerned so that CiviCRM can provide dynamic content.

## EDIT

Here's an example of when CiviCRM will use this page. You have an event, you want to give people a link to sign up for it.

From the Manage Events page you click (1) event links, then you see (2) test and live event registration links. You right-click the one you want and choose "Copy Link Location" (or whatever similar description your browser offers), and send people the link.

When people click that link CiviCRM will use the base page to decorate its sign up form.

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


title: Moving site from WordPress to Drupal

text:
# Question
Title: Moving site from WordPress to Drupal
I've been moving a CiviCRM from WordPress to Drupal but getting a strange array of errors.

It's on the same hosting so I've set up a new database for the new CiviCRM, moved all the tables except the 4 cache tables and the domain. I've cleared all the cache, rebuild menus, (attempted) to sync the users (only got about 180 out of 280 but that's a good start).

My problem is that a number of the pages in CiviCRM throw up the 'DB table does not exist' error: When I edit/create a contact Organisation address and contact info The page to edit the navigation menu opens but the triangle is just spinning Quick search doesn't work (nothing happens) but Find Contacts does work.

I've turned on the advanced logging, and getting errors like the following:

```
Notice: Undefined index: frontend_title in CRM_UF_Page_Group->browse() (line 329 of /home/xxx/www/data/sites/all/modules/civicrm/CRM/UF/Page/Group.php).

```

Any ideas?

Thanks

# Answer
> 3 votes
For some reason, the back up hadn't recorded the updated version of CiviCRM (it may have happened before I reran the update script) so when I checked the domain table in the back-up just now, it was still showing version 4.7.29. I did a manual back-up AFTER double-checking the domain/version was correct in the WordPress site, then I copied over the database tables again and it's working.

---
Tags: wordpress, drupal, installation
---


# Question
Title: CiviCRM 5.2.2 System Status gives Incorrect Resource URL (Drupal 7.5)
CiviCRM 5.2.2 (drupal 7.59, ubuntu 16.04.01, mysql 5.7.22, php 7.0.30)
CiviCRM System Status gives:
Incorrect Resource URL
The Resource URL is not set correctly. Please set the CiviCRM Resource URL.
Cause: In sites/all/modules/civicrm/CRM/Utils/Check/Component/Env.php
$arrowUrl = CRM\_Core\_Config::singleton()-\>userFrameworkResourceURL . 'packages/jquery/css/images/arrow.png';
$headers = get\_headers($arrowUrl);
is returning an empty array.
sites/all/modules/civicrm/packages/jquery/css/images/arrow.png exists
Site seems to be working Ok otherwise.
Thanks for your help.

# Answer
> 2 votes
Go to `Administer > System Settings > Resource URLs` and check that the first one 'CiviCRM Resource URL' is set - usually `[civicrm.root]/`

It's worth checking `Administer > System Settings > Directories` at the same time.

---
Tags: drupal, error
---


# Question
Title: Fatal DB query syntax error on rules search - Civi 5.0.0 and recent Civirules
I have 7 rules set up to help automate membership management. All are tagged with the same tag and all but one are active. WHen I search by tag or for all rules I get the correct result, but when I search by the tag AND all rules I get a DB query syntax fatal error. This is from the log:

\[db\_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM\_Core\_Error::handle prefix=""

info="SELECT COUNT(DISTINCT(crr.id)) AS total FROM civirule\_rule crr LEFT JOIN civirule\_trigger crtrigger ON crr.trigger\_id = crtrigger.id LEFT JOIN civirule\_rule\_tag crtag ON crr.id = crtag.rule\_id LEFT JOIN civicrm\_contact contact ON crr.created\_user\_id = contact.id **WHERE AND** (crtag.rule\_tag\_id = 1)

\[nativecode=1064 \** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND (crtag.rule\_tag\_id = 1)' at line 5\]"\]

I suppose that some condition is expected between **WHERE AND** that I emphasized in bold. This same error happens on Civirules 1.23 and 2.1. The upgrade also updated the database, but I tested on a separate, older system that had not been upgraded.

Could this be due to some database corruption or is it a bug?

# Answer
I do not know without checking on your site. I have recently tested 2.1 on an existing site and it worked there. You might want to check if the civirule\_condition table is still populated? It might be that it got accidently cleaned out.

If that is the case, you will have to take note of what your conditions/actions where, run the sql scripts **insertCiviRulesConditions** and **insertCiviRuleActions** from the sql folder of the extension to re-create them. And then you have to rebuild your rules in the UI.
> 1 votes

---
Tags: error, civirules, sql
---


# Question
Title: Text that doesn't appear on the contribution page
For my contribution page: https://crm.teatronecessariogenova.org/civicrm/?page=CiviCRM&q=civicrm/contribute/transact&reset=1&id=1 \- I checked the option: "Pay later"; in the editor I put the "Pay instructions later", but what I wrote in the editor doesn't appear on the "contribution" page. Thanks

# Answer
> 4 votes
The text that you add to the "Pay Later Instructions' box should show per the following:

> Instructions added to Confirmation and Thank-you pages, as well as the confirmation email, when the user selects the 'pay later' option (e.g. 'Mail your check to ... within 3 business days.').

You said:

> what I wrote in the editor doesn't appear on the "contribution" page

Unsure if you incorrectly typed 'contribution' instead of 'confirmation', or if you meant what you typed, in which case the text is not expected to show.

The other text "Pay later label" should show on the Contribution page, but may only after an amount has been selected if (assuming more than one payment option is set up)

Please add any clarification you can to your original question via 'edit'

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


# Question
Title: How to enter event registrations after event has ended
We are using Civi 5.0.1 on Wordpress 4.9

We had our conference two weeks ago. Most of the attendees signed up online through the website. We also allow attendees to Walk in and signup and pay during the event.
Today I was asked to enter the information for the people who walked in and paid during the conference. When I try to save their information for the event registration I get the error you see in the screenshot. I believe this is due to the event having ended. How can I add registrations and have them associated with an event that already ended?

# Answer
> 6 votes
It looks like you set end dates not just on the event, but on the price fields as well. If so, you can remove the end dates from the price fields and that should fix your issue.

Public registration will still be impossible. End dates on price fields are only necessary if that price option goes away before the event takes place (e.g. early bird pricing).

---
Tags: wordpress, civievent, registration, price-sets
---


title: Update Indices fails on 4.7.29

text:
# Question
Title: Update Indices fails on 4.7.29
With successful update from 4.7.25 to 4.7.29 there is a **Performance warning: Missing Indices** in CiviCRM System Status. When I click the *Update Indices* button, the error appears

`Operation failed: Update Indices
DB Error: unknown error`

Enabling debug mode does not provide any additional info.

# Answer
> 2 votes
We had similar problem this before and had to manually run mysql commands to fix the indices. This link might be useful to solve the problem.

HTH

Pradeep

---
Tags: issues, upgrade, indices
---


# Question
Title: Three self-canceling financial transactions for a single recurring contribution?
For recurring contributions, I am getting unusual results in the `civicrm_financial_trxn` table. Three very similar entries are created for each contribution, two of which cancel one another out.

Am I failing to grasp something about double-entry accounting, or are two of these records simply unnecessary?

Or perhaps my financial types are configured to do weird things. Perhaps there *should* be three entries, but at least one account code other than 1150 and 455-11 should be in play. If this is the case, how do I go about identifying the culprit financial account?

Below is a screenshot from the Bookkeeping Transactions Report:

Some notes:

* It's probably not sensitive, but I've changed the transaction number out of an abundance of caution. Note that the original number was the same for all three rows.
* Note that the first and second rows cancel one another out (the amount in the second row is negative).
* Note that the payment method is blank for the third row.

Below is a screenshot of the `civicrm_entity_financial_trxn` entities that feed into the report:

Possibly of note:

* There is a four-second delay between the first record and the other two.

**System Details:**
CiviCRM verion: 4.7.29
CMS: Drupal... ahem... 6
Payment processor: Authorize.net

# Answer
> 2 votes
Likely due to this issue. Looks like there is a PR to correct this with a milestone of 5.4.0, so I guess this problem persists in the current 5.2.1 release.

---
Tags: accounting, financial-accounts
---


# Question
Title: How to share the user profiles with other users?
The requirement is if Contact A's specific field values(custom fields) are matching with Contact B field values then Contact C(Admin) should b able to share Contact A's profile with contact B by civimail. The profile should be of drupal view page of type Civicrm Contacts I tried Fuzion tokens extension to attach the user id and use the link as template for civi mail- "http://localhost/example.com/profile-page-view?uf\_id={user.id}" but this will attach their own profiles(Recipients own profiles) Admin will be finding the matching contacts using advanced search and find matches and sends email Any help would be appreciated.

# Answer
You could use the custom field value as a Contextual Filter and hence only show results to B for contacts where the other contacts' custom field matches that of B. I am not quite clear on how to do this but getting the value from B and applying it as a filter on the view seems like it should be entirely feasible.

Alternatively could you consider basing this on Relationships between B and A.
> 1 votes

---
Tags: civimail, contacts, drupal-views
---


# Question
Title: Set group field of a contact as required
I need that when saving contact validate the entry of the group field. How can I do it?

# Answer
You will need to write small extension and then implement hook\_civicrm\_validateForm to validate group field and then throw error. Example

```
/**
 * Implements hook_civicrm_validateForm().
 *
 * @param string $formName
 * @param array $fields
 * @param array $files
 * @param CRM_Core_Form $form
 * @param array $errors
 */
function xxxx_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
  if ('CRM_Contact_Form_Contact' == $formName) {
    if (!empty($fields['group']) && !in_array(10, $fields['group'])) {
      $errors['group'] = ts('Group field contains invalid option.');
    }
  }
}

```

HTH

Pradeep
> 1 votes

---
Tags: groups
---


title: civiCRM: Resource Limit Is Reached

text:
# Question
Title: civiCRM: Resource Limit Is Reached
when I load the data from the Excel sheet, I have discovered that civiCRM makes excessive use of resources; how to set civi so that this does not happen? Thanks

# Answer
> 1 votes
This is not something you can do in CiviCRM AFAIK, this depends on the configuration of the server where CiviCRM is running. And I assume you mean you are importing data from a CVS file, and you do not do that every day.

---
Tags: configuration
---


# Question
Title: Can't edit repeat events after upgrade to 5.22
Wordpress 4.9

Prior to upgrade, when editing repeat event the prompt (popup) on saving offered three choices:

1 Only this event All others in the series will remain unchanged.

2 This event onwards Change applies to this event and all that come after it.

3 Every event Change applies to every event in the series.

After the upgrade only one choice is offered:

1 Only this event All others in the series will remain unchanged.

It works fine in sandbox but that's running 5.4 alpha. Is that safe to upgrade to?

# Answer
I can see at 5.2.2(D7) all three options when a repeated event is edited.

I believe there is no special condition that will hide other 2 fields. Can you check browser console if they are hidden? It might be because of theme.

HTH

Pradeep
> 2 votes

---
Tags: repeating-events
---


title: What is Mattermost / chat?

text:
# Question
Title: What is Mattermost / chat?
In several posts on this CiviCRM StackExchange site, I see references to people getting help via 'Mattermost'.

What is it and how do I use it?

# Answer
Mattermost is open source messaging software - see https://www.mattermost.org/

References to Mattermost within this CiviCRM StackExchange site generally refer to CiviCRM's online community chat system that uses the Mattermost software and is one of the various support resources for CiviCRM.

StackExchange uses a Question and Answer format which works well for many things but sometimes an interactive chat format is more appropriate.

You can access it at https://chat.civicrm.org/ Follow the links to create an account.

* It is organised into various public and private channels. Take note of the description of each channel and post your question in the most relevant one.
* If you're unsure which channel to use, try 'Town Square' or 'User Support'.
* Just ask your question. Don't ask if it's ok to ask.
* Choose the most appropriate channel and ask. Don't post the same question in multiple channels.
* It is possible to send "Direct Messages" to other users but don't use them, unless you know the person and you are sure they are the only one that can reply.
* Be nice! It is a community of fellow CiviCRM users who are often very helpful, but do remember no-one is obliged to help you.
> 7 votes

---
Tags: community
---


# Question
Title: Difference using primary vs main email address
What is the different between the main and primary email address? How are these two used by CiviCRM?

# Answer
> 6 votes
A contact can have several emails. To distinguish them, each has a category: is this her professional email, her private one...?

And no matter how many emails a contact has, civi needs to know which one to use when I want to mail the contact: it is the primary one. I might prefer I receive emails on my private address, but you might prefer your professional one.

Now it's becoming more confusing:

The categories of emails are shared with the categories (Locations) of physical addresses, so you have a "home" email address and an "work" one. I use them as private and professional emails respectively... and an extra category "main" (meant to be for the main office location) that is indeed confusing (I tend to hide this category)... and an extra "billing" email address that will be automatically created if the contact makes a donation

Even more confusing?

civimail can use a different "primary" address than the "primary" one (the one flagged "bulk email"), so you could receive the event registration confirmation on your primary email, but the newsletter on your "bulk" email.

Even more confusing?

A contact can have several bulk emails, so you could receive the newsletter to both your private and professional email

Civi is super flexible and can deal with a lot of different workflows from a lot of different organisations, but sometimes, the defaults are a bit confusing indeed.

I'd suggest you to look at what email (actually Location) categories you need, and disable the ones you don't need (eg. the "main" one), it's under /civicrm/admin/locationType?reset=1

Keep in mind that that list is shared between the physical addresses and the email ones.

---
Tags: email
---


title: Cant install extension E-mail API 1.17

text:
# Question
Title: Cant install extension E-mail API 1.17
wordpress 4.9

And recently upgraded to civicrm 5.22 CiviRules 2.1

Was working fine with older civirules and E-mail API 1.10

this is the error

```
CiviCRM_API3_Exception: "Could not find the SQL file."

#0 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Extensions.php(190): civicrm_api3("Extension", "install", (Array:1))
#1 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(453): CRM_Admin_Form_Extensions->postProcess()
#2 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess()
#3 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(61): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Extensions), "next", "Next")
#4 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Extensions), "next")
#5 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Extensions), "next")
#6 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("next")
#7 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(398): CRM_Core_Controller->run()
#8 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(156): CRM_Core_Page_Basic->edit(1, NULL)
#9 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Page/Extensions.php(121): CRM_Core_Page_Basic->run()
#10 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(309): CRM_Admin_Page_Extensions->run((Array:3), NULL)
#11 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:16))
#12 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#13 /home/domain/public_html/wp-content/plugins/civicrm/civicrm.php(1246): CRM_Core_Invoke::invoke((Array:3))
#14 [internal function](): CiviCRM_For_WordPress->invoke("")
#15 /home/domain/public_html/wp-includes/class-wp-hook.php(286): call_user_func_array((Array:2), (Array:1))
#16 /home/domain/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters("", (Array:1))
#17 /home/domain/public_html/wp-includes/plugin.php(453): WP_Hook->do_action((Array:1))
#18 /home/domain/public_html/wp-admin/admin.php(224): do_action("toplevel_page_CiviCRM")
#19 {main}

```

Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred. Could not find the SQL file.

# Answer
Yep, there is a typo in there. Fixed in the latest `master` : https://github.com/CiviCooP/org.civicoop.emailapi.
> 2 votes

---
Tags: civirules
---


# Question
Title: Recurring contribution report by LineItem financial type
I am looking for a report that lists recurring contributions by Line item financial type. I have tried the Find Contribution report, the Advanced Search, the contribution report Recurring Contributions... They all only query the Contribution table Financial Type. I need to query the Line Item financial type.

# Answer
> 1 votes
I think Extended report extension does provide Line item financial type filtering but not sure if they filter only recurring contribution. There are of Contribution reports with additional filter/fields available that are not present in core reports. You may need to add filter to show only recurring contribution using hook\_civicrm\_alterReportVar hook.

(Even Bookkeeping Transactions Report does filter financial type using line item FT.)

HTH

Pradeep

# Answer
> 0 votes
I do not think there is a standard report that shows the line item financial type, but I might be mistaken. You can query the table `civicrm_line_item` if you have some kind of BI tool?

---
Tags: recurring-contributions
---


title: CiviCRM Converting HTML tag to Entity

text:
# Question
Title: CiviCRM Converting HTML tag to Entity
we're having an issue with newsletters being sent out with broken images due to the opening and closing tags being converted to HTML entities.

e.g. `<img src="foo.jpg" />` is sent out as: `< img src="foo.jpg" />`

We don't have control over the CiviCRM install however it's running on Drupal 7.

I'm wondering if this is a simple fix I could instruct a client on doing themselves or if it will require more work.

Any insights would be greatly appreciated, thanks!

# Answer
> 1 votes
*I'm assuming you're using the default mailing Ux, not mosaico*

The default editor is wysiwyg, if you want to put html tags, click on the view source icon, and paste the html code you want.

You can switch back to wysiwyg to see the result.

As for the images, be aware that quite a few recipients aren't going to display the image (for privacy reasons), so you should consider putting an alt text and dimensions (width and height) on your img tag

---
Tags: drupal, issues, civicrm-entity, html
---


# Question
Title: How can I set the maximum number of processes?
I thought I had a fix, but I'm still getting a 500 error on importing a batch of 16 organizations. Host tells me CiviCRM is spawning more than 30 processes, which is the host's limit.

Trying to get Civi to work on my current host. It's a shared server with a decent host with their top tier plan. Moving everything for Civi isn't an option I'll consider since I have 40+ dev and low traffic sites set up on the account that are all working well within plan limits. I installed Civi there for my education. So if I have to buy Civi-specific hosting, I'd prefer to poke around first.

Any ideas how I can limit the number of processes Civi spawns on import?

# Answer
I don't know of any way to limit the processes. Importing is a large task since it's hitting so many fields, tables, etc. That means a lot of processes regardless of how many records you're importing. Shared servers often times have too low of limits to be able to fully use CiviCRM without running into issues. It's why we finally ended up just getting our own server, setting it up so that its minimums would still be more than enough for Civi, and then using it for all our sites.
> 2 votes

# Answer
CiviCRM isn't spawning processes directly, that's probably apache, or your web server. When using the web interface to do CiviCRM imports, and many other activities, CiviCRM uses some clever techniques to avoid things timing out, but that have other trade-offs in server requirements. This is probably not the only place where you might run into trouble.

FWIW, 30 processes should be adequate, I suspect the server is not setup optimally.

If you have the ability to import a csv file into a temporary table in your database first, there's also an option to do the import from a table, that might generate fewer processes.
> 2 votes

# Answer
A workaround would be to clone your website to your localhost development environment, do the import there, then replace the live database with the one from localhost. If you need to retain the live URL throughout this process, you can point it to localhost by editing your `hosts` file.

\[Aside: this is a good way to do CiviCRM upgrades too, since it is far easier to roll back and repeat if anything goes wrong\]
> 1 votes

---
Tags: import, 500
---


# Question
Title: CiviCRM Cannot add or update a child row: a foreign key constraint fails error after upgrading from 4.7.30 to 5.0.2
After running the command to upgrade the database I got a constraint violation error.

ERROR USERINFO: ALTER TABLE `civicrm_case` ADD CONSTRAINT `FK_civicrm_case_case_type_id` FOREIGN KEY (`case_type_id`) REFERENCES `civicrm_case_type` (`id`) \[nativecode=1452 \** Cannot add or update a child row: a foreign key constraint fails...

I tried adding the foreign key in the database but that did not work. I got this error: MySQL ERROR 1005: Can’t create table (errno: 150)

The Foreign Key exists on the my live site's db so I imported a db backup from the lives site. Ran the db update command again and got the same error.

How do I prevent the migration from deleting the foreign key?

This is my civicrm\_case:

CREATE TABLE `civicrm_case` (

> `id` int(10) unsigned NOT NULL AUTO\_INCREMENT COMMENT 'Unique Case ID', `case_type_id` int(10) unsigned NOT NULL COMMENT 'FK civicrm\_case\_type.id', `subject` varchar(128) COLLATE utf8\_unicode\_ci DEFAULT NULL COMMENT 'Short name of the case.', `start_date` date DEFAULT NULL COMMENT 'Date on which given case starts.', `end_date` date DEFAULT NULL COMMENT 'Date on which given case ends.', `details` text COLLATE utf8\_unicode\_ci COMMENT 'Details about the meeting (agenda, notes, etc).', `status_id` int(10) unsigned NOT NULL COMMENT 'Id of case status.', `is_deleted` tinyint(4) DEFAULT '0', PRIMARY KEY (`id`), KEY `index_case_type_id` (`case_type_id`), KEY `index_is_deleted` (`is_deleted`) ) ENGINE=InnoDB AUTO\_INCREMENT=147 DEFAULT CHARSET=utf8 COLLATE=utf8\_unicode\_ci;

# Answer
A workaround to this is to comment out the SQL lines in the file that drop, modify and rebuild the FK. /CRM/Upgrade/Incremental/sql/4.6.18.mysql.tlp

This will have to be done for every upgrade with a db that does not include the FK.
> 2 votes

# Answer
That doesn't really make sense because there are no updates to that table in upgrading from 4.7.30 to 5.0.2

Here is how that table should look

`CREATE TABLE `civicrm_case` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique Case ID',
 `case_type_id` int(10) unsigned NOT NULL COMMENT 'FK to civicrm_case_type.id',
 `subject` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Short name of the case.',
 `start_date` date DEFAULT NULL COMMENT 'Date on which given case starts.',
 `end_date` date DEFAULT NULL COMMENT 'Date on which given case ends.',
 `details` text COLLATE utf8_unicode_ci COMMENT 'Details about the meeting (agenda, notes, etc).',
 `status_id` int(10) unsigned NOT NULL COMMENT 'Id of case status.',
 `is_deleted` tinyint(4) DEFAULT '0',
 `created_date` timestamp NULL DEFAULT NULL COMMENT 'When was the case was created.',
 `modified_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When was the case (or closely related entity) was created or modified or deleted.',
 PRIMARY KEY (`id`),
 KEY `index_case_type_id` (`case_type_id`),
 KEY `index_is_deleted` (`is_deleted`),
 CONSTRAINT `FK_civicrm_case_case_type_id` FOREIGN KEY (`case_type_id`) REFERENCES `civicrm_case_type` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;`

What is in civicrm.domain.version?
> 1 votes

---
Tags: upgrade, database
---


# Question
Title: Civirules can't add activity parameter "CiviCRM_API3_Exception: "Expected one OptionValue but found 2
wordpress 4.9 civi5.22 civirules 2.1

Add an action "add activity to contact" Then try to add condition (ie activity type) produces error ""CiviCRM\_API3\_Exception: "Expected one OptionValue but found 2" no choice but to return to home page.

A popup then confirms that activity parameter is saved (and it is added to civirule\_rule\_action table)

The rule does actually work but can no longer be accessed - any attempt to edit results in same error message. Also can't be deleted.

backtrace and full error as follows:

```
CiviCRM_API3_Exception: "Expected one OptionValue but found 2"

#0 /home/domain/public_html/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/CivirulesActions/Activity/Add.php(103): civicrm_api3("OptionValue", "getvalue", (Array:3))
#1 /home/domain/public_html/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/Form/Rule.php(387): CRM_CivirulesActions_Activity_Add->userFriendlyConditionParams()
#2 /home/domain/public_html/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/Form/Rule.php(282): CRM_Civirules_Form_Rule->getRuleActions()
#3 /home/domain/public_html/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/Form/Rule.php(258): CRM_Civirules_Form_Rule->createUpdateFormElements()
#4 /home/domain/public_html/wp-content/uploads/civicrm/ext/org.civicoop.civirules/CRM/Civirules/Form/Rule.php(34): CRM_Civirules_Form_Rule->createFormElements()
#5 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(570): CRM_Civirules_Form_Rule->buildQuickForm()
#6 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Display.php(92): CRM_Core_Form->buildForm()
#7 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform(Object(CRM_Civirules_Form_Rule), "display")
#8 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Civirules_Form_Rule), "display")
#9 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("display")
#10 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Wrapper.php(113): CRM_Core_Controller->run()
#11 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(283): CRM_Utils_Wrapper->run("CRM_Civirules_Form_Rule", "Rule", NULL)
#12 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#13 /home/domain/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
#14 /home/domain/public_html/wp-content/plugins/civicrm/civicrm.php(1246): CRM_Core_Invoke::invoke((Array:4))
#15 [internal function](): CiviCRM_For_WordPress->invoke("")
#16 /home/domain/public_html/wp-includes/class-wp-hook.php(286): call_user_func_array((Array:2), (Array:1))
#17 /home/domain/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters("", (Array:1))
#18 /home/domain/public_html/wp-includes/plugin.php(453): WP_Hook->do_action((Array:1))
#19 /home/domain/public_html/wp-admin/admin.php(224): do_action("toplevel_page_CiviCRM")
#20 {main}

```

# Answer
I have recently (with the latest CiviRules version) succesfully used this rule in combination with the same condition. My first step would be to check your activity types and make sure there is not a double one in there (with the same name rather than label)
> 1 votes

---
Tags: civirules
---


# Question
Title: Can't find HTML Snippet in Profiles (Drupal)
I want to use the HTML snippet.

But i don't find the path to active "Accept profile submissions from external sites to Yes".

i'm using CiviCRM 4.7.29 running with Drupal.

any idea ?

# Answer
> 2 votes
This is available under **Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.)** (CiviCRM \>\> Administer \>\> System Settings \>\> Misc (Undelete, PDFs, Limits, Logging, Captcha, etc.))

> Note: Try clearing CiviCRM cache if you still unable to see it under Misc.

HTH

Pradeep

---
Tags: form-snippets
---


title: Civirules send sms not working

text:
# Question
Title: Civirules send sms not working
wordpress 4.9 civi 5.22 civirules 2.1 SMSAPI 1.5

No activity is added and no sms is sent

And this question doesn't meet quality standards so I'm adding some more text Provider is clickatell. I can send sms through Civi without using civirules. Worked fine previously. I’m not sure whether the upgrade to Civi 5.22 or the upgrade to civirules 2.1 is the cause as upgrades were contemporaneous. There are no error messages and I don’t know which logs might help. It’s 4am my time and I have been struggling for hours with a number of post upgrade issues with some excellent help from this forum. I eat muesli for breakfast, have 2 dogs and consider civirules to be one of the most useful extensions ever (even though it is currently giving me grief.

# Answer
That was the clue - put a five minute delay on the sms action - the condition is checked again and Voila the sms is sent. So perhaps this needs to be added to the docs. It might be only the action "send sms" that needs a delay. Sending an email or adding a tag work fine via a profile.
> 3 votes

---
Tags: civirules
---


title: can CiviCRM reports be archived?

text:
# Question
Title: can CiviCRM reports be archived?
Is there any way to archive reports in CiviCRM so they are still available but no on the long list of reports?

# Answer
> 2 votes
I am not sure if we can. One option is to disable report template but it will disable all the reports associated with the template, which i believe you don't want.

However there is column(is\_active) in civicrm\_report\_instance to set report Active/In-active but the report list is not filtered on this field(See here). So adding a where clause `AND inst.is_active = 1` will list only active reports and then update all the report instances that you would like to archive to set is\_active = 0 through api explorer (CiviCRM \>\> Support \>\> Developer \>\> API Explorer)

Alternate option will be to create a dummy user and assign all the report instances that you would like to archive to dummy user contact through api(so all assigned reports will be visible to dummy contact user only and then set it NULL when you want the report to be visible for all)

HTH

Pradeep

---
Tags: civireport
---


# Question
Title: How can I tell if Remote Profiles are in use?
Remote profiles are difficult to configure safely, so they're turned off by default on modern CiviCRM installs. However, if I have an old CiviCRM installation, how can I tell if this feature is in use before I turn it off?

# Answer
It's not 100% but you can identify submissions that are local origin by referer in the web logs.

Additionally, any POST that is not from an external form will have a preceding GET for the same form path, while a POST that is a profile submission from remote origin will not. Good opportunity to practice a little awk
> 3 votes

---
Tags: profile, security, form-snippets, snippet
---


# Question
Title: Drupal CiviCRM Contact View -- Show all groups for a contact
Ok, this should be very straight forward but it doesn't appear to be.

I have a CiviCRM Contact View in Drupal 7. It is a contact search of sorts. When a contact is rendered a number of things are displayed. The contacts can be a member of one or more CiviCRM Groups and I would like to display a comma delimited list of the groups that each contact belongs to. At present Drupal Views only displays the first group.

Any ideas of how to render more?

# Answer
> 1 votes
I've resolved this for my needs and here is my solution in case anyone else needs to do the same thing.

I would have liked to use the Views Aggregator Plus module however I am not using a table for rendering my results and I have somewhat specific needs for the way the results are formatted.

My solution was to create Custom Views Field and in my field handler, I queried the CiviCRM API to pull all of the Groups per Contact ID. In order to limit the Groups to the ones I wanted to render, I used the Visibility setting for "Public Pages" and put a conditional in the loop that produces the results.

Hooks: hook\_views\_data() hook\__views\_api()

In my views filed handler inc file I created a class that extends views\_handler\_field to run my logic and return my results.

I acquired the contact id and placed it in avariable called $contactid then used the following CiviCRM API code to get my groups array

```
$groups = civicrm_api3('GroupContact', 'get', array(
  'sequential' => 1,
  'contact_id' => $contactid,
));

```

The rest was pretty straight forward looping and concatenating the string of Group Titles.

# Answer
> 2 votes
You can use Views Aggregator Plus module to group contact 2 rows.

**Views Setting**

**Table format setting**

**Result**

HTH

Pradeep

---
Tags: drupal, drupal-views
---


title: Why can't I upload images to mailings?

text:
# Question
Title: Why can't I upload images to mailings?
I'm using civiCRM 4.6 Wordpress 4.1.5 hosted on Bluehost.

Can you upload images to mailings via image properties\>upload\>send to server?

This seems to navigate to page that doesn't exist and the image does not get uploaded.

If you go to image properties \> browse server it just navigates to this page: http://lmysite/wp-content/plugins/civicrm/civicrm/packages/kcfinder/browse.php?cms=civicrm&type=images&CKEditor=crmUiId\_1&CKEditorFuncNum=3&langCode=en and says page not found (with my header and footer).

I think my directories are correct. image upload url: http://mysite/wp-content/plugins/files/civicrm/persist/contribute/

resource URL: http://mysite/wp-content/plugins/civicrm/civicrm/

And my civicrm.settings: $civicrm\_root = '/serverpath/public\_html/wp-content/plugins/civicrm/civicrm/'; if (!defined('CIVICRM\_TEMPLATE\_COMPILEDIR')) { define( 'CIVICRM\_TEMPLATE\_COMPILEDIR', '/serverpath/public\_html/wp-content/plugins/files/civicrm/templates\_c/' ); }

I don't know if this is also related to another unresolved problem I have to do with mailings: Why do 'track click through' links not redirect to correct address?

This seems to be related but is for Joomla: https://civicrm.org/blogs/kurund/enable-image-uploads-and-server-browsing-for-ckeditor

This is a similar problem but the conclusion is unclear: http://forum.civicrm.org/index.php?topic=30066.0

# Answer
> 1 votes
This may have been a bug in 4.6.0. Can you try upgrading to the latest version and see if that fixes it?

# Answer
> 1 votes
If it said "Cannot find any of the supported PHP image extensions!" or it does not appear sometimes

**Try go to php.ini, enable ;extension=php\_gd2.dll by removing ";"**

# Answer
> 0 votes
Just wanted to note - ran into the same kind of problems. Turns out that for some reason when the civicrm file extracted it didn't add the right account user for the owner of all the files. Fixed that and everything works fine now. Just figured I'd post this in case someone else ran into the same problem. :)

# Answer
> -1 votes
I am having the exact same problem. I upgraded 9 civi sites today and this is the only one that is causing me problems. Checked resources directorys, civi settings file and everything appears to be correct. This was not an issue prior to the upgrade on 4.6.8. Scratching my head.

---
Tags: civimail, wordpress
---