# Question
Title: How to get a CiviRule to fill in a custom field upon a webform submission?
We have a Drupal 7 website that we are having users submit a webform on. When a webform is submitted it is assigned a unique ID. This ID used to generate a PDF to view the webform results and is viewable on the Drupal side. The problem we are running into is getting this information over to the CiviCRM side automatically. We created a custom data field in CiviCRM for the ID to go in and have it left blank during the submission, and we installed the module CiviRules Webform CiviCRM Submission Trigger so we can have a rule run when the form is submitted. The part we need help with is getting a rule that takes that ID and fills in the blank field with it upon submission or some way to do the equivalent.

# Answer
You will probably need to develop an action that can take that ID from the data coming into the action and set it. There is a standard action to update a custom field (Set Custom Field) but it will ask for a value and will not be able to pick up the value from the input just like that.

Developing your own action is documented here: https://docs.civicrm.org/civirules/en/latest/create-your-own-action/

An alternative might be to use the Form Processor extension, and pick up the ID from the incoming data like that. Check the documentation here: https://docs.civicrm.org/formprocessor/en/latest/
> 1 votes

# Answer
One option is to use https://www.drupal.org/project/webform\_conditional\_values with Webform-CiviCRM integration if the ID is known before submission. If it's not available until after submission, you'll need to write code. Erik suggests one way, you could also write a Drupal module to push it to Civi.
> 1 votes

# Answer
If you are not developers, you can hire one from https://civicrm.org/partners-contributors, including ErikH or Jon G (or us ;) ).
> 0 votes

---
Tags: custom-fields, webform-civicrm, civirules, drupal-7
---


# Question
Title: Field 'Type' in Contacts -> GetFields API
What does the 'type' refer to in the results of 'getfields' action of the Contact Entity. It has a numeric value (1,2, 16 etc). Below are a few sample results.

```
        "id": {
        "name": "id",
        "type": 1,
        "title": "Contact ID",
        "description": "Unique Contact ID",
        "required": true,
        "import": true,
        "where": "civicrm_contact.id",
        "headerPattern": "/internal|contact?|id$/i",
        "export": true,
        "table_name": "civicrm_contact",
        "entity": "Contact",
        "bao": "CRM_Contact_BAO_Contact",
        "localizable": 0,
        "add": "1.1",
        "is_core_field": true,
        "api.aliases": [
            "contact_id"
        ]
    },
    "contact_type": {
        "name": "contact_type",
        "type": 2,
        "title": "Contact Type",
        "description": "Type of Contact.",
        "maxlength": 64,
        "size": 30,
        "where": "civicrm_contact.contact_type",
        "export": true,
        "contactType": null,
        "table_name": "civicrm_contact",
        "entity": "Contact",
        "bao": "CRM_Contact_BAO_Contact",
        "localizable": 0,
        "html": {
            "type": "Select",
            "maxlength": 64,
            "size": 30
        },
        "pseudoconstant": {
            "table": "civicrm_contact_type",
            "keyColumn": "name",
            "labelColumn": "label",
            "condition": "parent_id IS NULL"
        },
        "add": "1.1",
        "is_core_field": true
    },
    "contact_sub_type": {
        "name": "contact_sub_type",
        "type": 2,
        "title": "Contact Subtype",
        "description": "May be used to over-ride contact view and edit templates.",
        "maxlength": 255,
        "size": 45,
        "import": true,
        "where": "civicrm_contact.contact_sub_type",
        "headerPattern": "/C(ontact )?(subtype|sub-type|sub type)/i",
        "export": true,
        "table_name": "civicrm_contact",
        "entity": "Contact",
        "bao": "CRM_Contact_BAO_Contact",
        "localizable": 0,
        "serialize": 1,
        "html": {
            "type": "Select",
            "maxlength": 255,
            "size": 45
        },
        "pseudoconstant": {
            "table": "civicrm_contact_type",
            "keyColumn": "name",
            "labelColumn": "label",
            "condition": "parent_id IS NOT NULL"
        },
        "add": "1.5",
        "is_core_field": true
    },
    "do_not_email": {
        "name": "do_not_email",
        "type": 16,
        "title": "Do Not Email",
        "import": true,
        "where": "civicrm_contact.do_not_email",
        "headerPattern": "/d(o )?(not )?(email)/i",
        "dataPattern": "/^\\d{1,}$/",
        "export": true,
        "default": "0",
        "table_name": "civicrm_contact",
        "entity": "Contact",
        "bao": "CRM_Contact_BAO_Contact",
        "localizable": 0,
        "html": {
            "type": "CheckBox"
        },
        "add": "1.1",
        "is_core_field": true
    }

```

# Answer
`type` is the data type - eg Integer, String, Boolean.

If you use APIv4 `Contact.getfields` returns `data_type` with more obvious strings. For example:

```
"data_type": "Integer"

"data_type": "String",

```
> 1 votes

---
Tags: contacts, api, contact-types
---


# Question
Title: Using price sets for renewing memberships on online pages?
I want to provide a signin to a membership with CiviCRM contribution pages. I configured an auto-renew membership with a Membership Type Duration Unit = 1 month..

Then i set up a price set. The price set is configured with different prices and terms, lets say

* quarterly with a number of terms = 3 for 30 €
* yearly with a number of terms = 12 für 100 €.

Both is now included in a contribution page, with a payment processor and enabled membership section.

When filling out the forms and submitting on the contribution page like `civicrm/contribute/transact?reset=1&id=1`, the membership is recorded with the right terms (eq. 12 month), but the recurring contribution is recorded as monthly payment, eq. `100 € every month`, which is not right.

On the confirmation page (before submitting the form) it also shows `I want to contribute this amount every month` instead of `every 12 month`.

Papypal is used as payment processor, but i have also tried credit card.

Is this expacted behaviour and did i misunderstood the price sets?

thanks a lot, kindly regards

# Answer
It would be nice if it worked as you have set it up but multiple terms are not compatible with auto-renew.

The documentation for multiple membership terms includes this caveat at the end:

> However you need to be aware that your members will not be able to auto-renew if you use this type of multi-term configuration.
> 1 votes

---
Tags: civimember, price-sets
---


title: Fails to open ClassLoader.php file

text:
# Question
Title: Fails to open ClassLoader.php file
I've installed the plugin successfully, but when I go visit the CiviCRM page in the backend, I get the following error:

Warning: require\_once(CRM/Core/ClassLoader.php): failed to open stream: No such file or directory in /home/capitaleventscom/public\_html/wp-content/uploads/civicrm/civicrm.settings.php on line 462

Fatal error: require\_once(): Failed opening required 'CRM/Core/ClassLoader.php' (include\_path='.:/home/capitalevents/public\_html/wp-content/plugins/civicrm/civicrm/:/home/capitalevents/public\_html/wp-content/plugins/civicrm/civicrm//packages:.:/usr/local/php56/pear') in /home/capitaleventscom/public\_html/wp-content/uploads/civicrm/civicrm.settings.php on line 462

I've tried but couldn't figure out anything. Any help will greatly be appreciated.

# Answer
In the file `civicrm.settings.php` the variable `$civicrm_root` is defined. It should point to the directory where you installed the CiviCRM plugin. If it has the wrong value it causes the reported error.
> 4 votes

# Answer
Agreed with the @Kainuk answer. Here is what i did today to solve the same error. In your civicrm.settings.php if you have

```
require_once 'CRM/Core/ClassLoader.php';

```

Change it by adding "civicrm\_root" variable

```
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';

```

This is assuming that somewhere in that file, you have already set the "$civicrm\_root" variable to point to your civiCRM install directory such as

```
$civicrm_root = '/var/www/html/drupal-root/vendor/civicrm/civicrm-core';

```
> 1 votes

---
Tags: wordpress, civievent
---


# Question
Title: Error: require_once(): Failed opening required 'CRM/Core/ClassLoader.php'
PHP Error: require\_once(): Failed opening required 'CRM/Core/ClassLoader.php' (include\_path='.:/buildkit/build/dmaster/web/sites/all/modules/civicrm/:/buildkit/build/dmaster/web/sites/all/modules/civicrm//packages:.:') at line 552 in /Users/apple/Work/Gsoc/Opensrc/civicrm-buildkit-docker/build/dmaster/web/sites/default/civicrm.settings.php

This is the complete error i am getting. For this i changes the path in civicrm.setting.php '''$civicrm\_root ='/Users/apple/Work/Gsoc/civicrm/civicrm-buildkit-docker/build/dmaster/web/sites/all/modules/civicrm';''' even then i am getting the same error. Please help me out.

# Answer
> 2 votes
I'm using drupal with civiCRM and got the same error \[failed to open require\_once CRM/Core/ClassLoader.php\]. I made the following changes to solve it.

In your civicrm.settings.php if you have

```
require_once 'CRM/Core/ClassLoader.php';

```

Change it by adding "civicrm\_root" variable

```
require_once $civicrm_root . '/CRM/Core/ClassLoader.php';

```

This is assuming that somewhere in that file, you have already set the "$civicrm\_root" variable to point to your civiCRM install directory such as

```
$civicrm_root = '/var/www/html/drupal-root/vendor/civicrm/civicrm-core';

```

Note: my path might be different as I'm using composer to install civiCRM

---
Tags: mosaico, integration
---


# Question
Title: Membership Status not updating beyond Grace to Expired
The Grace status is set to end 2 years after Membership End Date. At that point the Expired status should kick in. The Grace status is activated correctly at Membership End Date, but that status is NOT ending at the "after 2 years" mark.

The Scheduled Job for updating membership status is executing OK.

Some of our memberships are now 3 years or more past their End Date - does the system recognise those old dates and update status accordingly? Or should these be manually overwritten?

# Answer
> 1 votes
It sounds like there's a misconfiguration of your Membership Status Rules.

Please review them at **Administer menu \>\> CiviMember \>\> Membership Status Rules**. Pay special attention to the Grace and Expired rules, especially to the Start Date Adjustment and End Date Adjustment.

If you're not sure how to interpret what you're seeing, feel free to edit your question to include screenshots.

# Answer
> 1 votes
Issue was resolved by having Grace status End Date Adjustment set to 24 months after the membership end date. The Expired status was left with a Start Date of 2 years after the membership end date. For some reason if the two timings were set to be the same (i.e. 2 years or 24 months) the Expired status never kicked in.

---
Tags: civimember
---


# Question
Title: How enable eventcart extension in WordPress CiviCRM?
after an update of wp civicrm plugin from 5.16.4 to 5.30.1. (WordPress is also up to date). When I subscribe to an event this fatal error appear : PHP message: PHP Fatal error: Uncaught Error: Class 'CRM\_Event\_Cart\_BAO\_Conference' not found in civicrm/CRM/Event/BAO/Event.php:1133

File : "civicrm/CRM/Event/BAO/Event.php:1133"

`$sessions = CRM_Event_Cart_BAO_Conference::get_participant_sessions($participantId);`

Maybe the problem is due to a wrong setting ? I kept my old civicrm.settings.php as it is after update.

It seems eventcart extension is not installed or activated. I mean this extension : wp-content/plugins/civicrm/civicrm/ext/eventcart/

Do you know how install/enable it?

Thank you for you help. Nicolas

# Answer
As of this writing event cart should be enabled but hidden, and currently still relies on the setting under Administer - CiviEvent - Component Settings to switch on and off features. You can verify if the extension is enabled by running this SQL: `select is_active from civicrm_extension where name='eventcart';`

If it's not, in civi go to Support - Developer - api explorer v3 and choose Entity=Extension, and Action=Enable, and for the key parameter put `eventcart`. Then click execute at the bottom. The upgrade should have done that though. There should be a record that it did that in ConfigAndLog.
> 2 votes

# Answer
I found the solution. The reason was very simple. In my settings file located in WordPress upload files, I set : `$civicrm_root = dirname(__FILE__).'/../../plugins/civicrm/civicrm/';`

I change it into absolute real path : `$civicrm_root = /var/www/html/mysite/html/wp-content/plugins/civicrm/civicrm/';`

After that, I was able to enable the extension "eventcart" with api explorer v3. It seems the "../" is not allowed by civi in last version.

Nicolas
> 1 votes

---
Tags: wordpress, civievent, extension, modules
---


title: Need to see latest incoming messages

text:
# Question
Title: Need to see latest incoming messages
we are a small charity who would like to see all the latest incoming enquiries from our website in one place when we log on to civicrm in wordpress.

We have created a general enquiry form (Caldera Forms) which does send an email direct to the specified charity email address, and does create an individual record at the backend of civicrm, but none of them show up in the activities screen when we log in.

It would be very useful to be able to see in one place the messages that we need to deal with as they come in.

Grateful in advance for any help on this please.

# Answer
> 2 votes
As @petednz mentioned, it does sound like that your entries are being merged. You can check what dedupe rule Caldera form is using under the Contact 1 processor. if you didn't create a dedupe rule that always create a new record, then it is likely that it will use an existing rule that merges the new entries. To create a dedupe rule that doesn't merge, you need to get to CIVICRM and go to Contacts\>Find and Merge Duplicate Contact and create a rule under the Individual Section. Click Add Rules for the section and i suggest the following entries:

Rule Name = Always No Merge

Usage = General

Reserve = No tick

Field = Address Name

Weight (same row as Address Name) = 10

Skip the rest of the rows

Weight Threshold to Consider Contacts 'Matching':100

the idea is to set a dedupe rule that will never be matched, more on how the dedupe rule works is here: https://docs.civicrm.org/user/en/latest/common-workflows/deduping-and-merging/

then go back to Caldera Contact 1 Processor and refresh the browser. You should see the new dedupe rule "Always No Merge" listed there for you to select. Any new entries would be a new record now. However, if the records do belong to the same individual, you would have the merge the records manually.

# Answer
> 1 votes
Do you create Activity from Caldera form when user submits the Enquiry form? If not than you will need to add Processor to create an activity against the contact who submitted the form.

# Answer
> 0 votes
There are several ways to get a single view of the new messages. if you are using activity processor, then setting it up to record as an associated activity with the contact record should work (https://github.com/mecachisenros/cf-civicrm/blob/master/docs/processors.md). The other ways are to use the tag processor to add tags or use a group processor to add the contact to a designated group. you can then use the CIVICRM dashboard to be updated on new entries.

However, Activity Processor should work, perhaps you want share how you setup the processor, it should be similar to the link i listed above.

---
Tags: wordpress, email, activities
---


# Question
Title: Can multiple websites be synchronized under the same CRM installation
I am very new to CiviCRM so I'm sorry if this sounds silly. I want to ask if you can install the CRM on one website, but manage/gather/synchronize the activities from another one. As an idea, I will try it on Wordpress, but the question is generic.

For example, the main website is one of the main organization (which has various activities, products etc.), where Civi would be installed, then there is another one, like an online shop for example (with products mngmt., sales, marketing actions etc.) which needs to send its activities to the main website too.

Can that be achieved? If yes, is it possible with just one Civi instance or there needs to be an instance on each wesite? In any case, I'm really excited about this platform that I recently found out about and it seems absolutely amazing.

Thanks for any feedback. Andy

# Answer
It is possible to have a single civicrm wired to several CMS instances.

There is some documentation here

https://docs.civicrm.org/sysadmin/en/latest/install/multi-site/

There are hurdles to get over, for example, how to synch users across the various CMS

There are other approaches to pull in data from other sites without wiring CiviCRM in to it including

Some good answers here

Perhaps best if you want more input on this Q+A to add more info to your Question detailing a bit more including how you see logged in users functioning across the sites
> 1 votes

---
Tags: wordpress, multisite, sync
---


title: CiviRule triggers 2Xs

text:
# Question
Title: CiviRule triggers 2Xs
I have created a CiviRule that Triggers on "Email address is added" with a linked condition of "Field Value Comparison Email.is\_primary = 1"

It is triggering and the action is happening. However, it is happening 2Xs. Which shows an error message to our users.

In API4, if I select Email \> get -\> Where Contact id = xxx; it shows 2 results. If I select Email \> get -\> Where Contact id = xxx & -\>Where email is primary - yes; it shows 1 result.

The activity that is happening when this triggers is a contribution from a first-time donor. Any ideas why the Link Condition above does not limit my trigger to 1X? Thanks

Here are the screenshots of the Rule setup per request of jitendra

EDIT: I added more information being sent to the logs. I can now see the Email ID # along with the condition value (per suggestion of ErikH). It is not getting the correct condition on "Email is Primary=1". That is showing 1 for both times but the email table has one with 1 and one with 0.

I added to the condition "& Location Type=Home" Now it just processes the rule 1x.

# Answer
> 2 votes
Check to see what your default email location type is and add that as the second condition: "AND Location Type = \[default\]"

The issue was that both email table entries (Home & Billing) are initially created as Primary. But the non-default email is then updated to not Primary. So the CiviRule processes before the non-default email update happens. .

Thanks to ErikH and Aidan for their help in troubleshooting this.

---
Tags: civirules
---


# Question
Title: Transfer/cancel booking gives error message
We use the CiviCRM event-booking feature on our website. The self-service cancel/transfer option isn't enabled, so attendees who want to cancel their booking for an event will email or call us and we cancel their place manually by logging in as administrators. I haven't had to do this for a while, and it's not now working.

\[!\[Find Participants screen for an event\]\[1\]\]\[1\] \[1\]: https://i.stack.imgur.com/rPD6B.png

I tried to do this by logging in to our Wordpress site and going to: CiviCRM \> Events \> Manage Events \> Find Participants \> More \> Transfer or Cancel, as hopefully shown in the image above.

The error I get is "Sorry. This event registration can not be transferred or cancelled. Contact the event organizer if you have questions."

When logged in as an admin, should this option work, regardless of whether self-service is enabled?

Thanks very much for any suggestions.

# Answer
This is a new addition in core via https://github.com/civicrm/civicrm-core/pull/18067. You MUST have the below setting enabled in event -\> online registration tab to transfer or cancel participants belonging to that event.
> 3 votes

---
Tags: civievent
---


# Question
Title: uploading new contacts with relationships
We are using civi to help us fundraise for our school. Each year we upload the new parents to the database from a csv from schoolbase. We need to add a relationship for each parent to their child(ren). This is important, because the communications we send vary based on the children's D.O.B (this enables us to tell which school year they are in without updating it every year). Is there a way to import these relationships at the same time as importing the contacts? Is this just a question of using correct field mapping? If they have more than one child would you need to have all the children in the same field? I'm assuming you'd need to import the children separately first, is that right?

# Answer
> 3 votes
Welcome to SE! Yes, you can import the relationship at the same time. The documentation describes your situation here.

This is based on one row per child with parent details in the columns. You import once for child, mother, relationship and once for child, father, relationship.

Check that your default dedupe rules work for the parent fields you are importing to avoid duplicates being created.

You don't need to do anything special where more than one child has the same parents other than check the dedupe rules. Each child is a separate line.

I'd suggest trying this on a test system first to become familiar with the process and check your dedupe rules are working as desired.

Try following the steps in the documentation and let us know if you have further questions.

---
Tags: contacts, relationships, upload, fundraising
---


# Question
Title: Reason for no Views Relationship from CiviCRM Contact to Event Participant
I am trying to write a Drupal View (with VBO) to show CiviCRM Contacts with the Event Participant records which they are related to. But there is no suitable Relationship in the standard list. I have enabled both Contact and Participant (and Event) entities in Civicrm\_Entity, and would presume that this is where the Relationship would be generated as well.

I can use the hook\_views\_data\_alter() to create the Relationship, so there is no fundamental reason why it should not work.

Is there a reason why Civicrm\_Entity does not provide this, or is it a bug?

# Answer
We do have D7 VBO Views like this for clients -\> key is to start with a CiviCRM Participant View - so that the base table is `civicrm_participant` \- from there you can add a Relationship to the Contact to get at the Contact fields like Last Name etc.

Note there there is a bug in the API in that after updating participant status. It will change is\_test to = NULL and that removes the Participant record from the CiviCRM UI.

One solution that jackrabbithanna pointed out is to expose the is\_test field as well and then specifically add 0. I've not tried that yet though!
> 1 votes

---
Tags: drupal-views, civicrm-entity, drupal-7
---


# Question
Title: How can I run the Drupal 9 Webform CiviCRM unit tests on my local?
D9 Webform CiviCRM now has automated functional javascript testing! How can I run these tests on my local?

# Answer
Ok here are the steps!

I'm on a Mac/MAMP and I use PhpStorm

**A. Get Drupal**

```
composer create-project drupal/recommended-project:8.9.13 d8civicrm.local
cd d8civicrm.local

composer config extra.enable-patching true
composer config minimum-stability dev

```

**B. Get CiviCRM**

```
composer require civicrm/civicrm-core:5.35.0 civicrm/civicrm-packages:5.35.0 civicrm/civicrm-drupal-8:5.35.0 civicrm/civicrm-asset-plugin:~1.1

```

**C. Install Drupal**

Browser to your new website -\> in my case: http://d8civicrm.local and follow the install step in the UI.

**D. Make it writeable**

```
chmod -R +w d8civicrm.local

```

we need to write e.g. the `civicrm.settings.php` file next!

**E. Install CiviCRM**

Go to the UI -\> Extend -\> or use drush!

**F. Patch alert!**

No longer needed!

**G. PHPUnit configuration**

copy this file: https://gist.github.com/mglaman/efcdb804dcced6ddc856e9e0050aad1e -\> into /Applications/MAMP/htdocs/d8civicrm.local (i.e. where your composer.json is) and make updates specifically add in your `BASE_URL` and your `DB` location and credentials:

```
19c19
<     <env name="SIMPLETEST_BASE_URL" value="http://d8civicrm.local"/>
---
>     <env name="SIMPLETEST_BASE_URL" value=""/>
21c21
<     <env name="SIMPLETEST_DB" value="mysql://myadminuser:db^88*@localhost:3306/d8civicrm_local"/>
---
>     <env name="SIMPLETEST_DB" value=""/>

```

Note: when testing CiviCRM Extensions -\> add this line as well - as per docs: docs -\> https://docs.civicrm.org/dev/en/latest/testing/mink/

```
<env name="DEV_EXTENSION_DIR" value="/Applications/MAMP/htdocs/d9civicrm.local/web/sites/default/files/civicrm/ext/"/>

```

**H. Install webform module**

composer require 'drupal/webform:^6.0'

**I. Install webform\_civicrm module**

-\> (at this points the tests have not been released yet so you'll need to clone the webform civicrm github repo):

```
git clone https://github.com/colemanw/webform_civicrm.git --branch 8.x-5.x

```

**J. Get the Drupal Dev tools**

We started with `drupal-recommended` \- now let's get the dev tools:

```
composer config minimum-stability dev
composer require drupal/core-dev-pinned:^8.9 --no-suggest

```

Note: reproducing this just now - I ended up having to `rm composer.lock` and `rm -r vendor` as it was spitting out a symfony conflict. Ah looks like in the `.github/workflows/main.yml` file we install the drupal dev tools before we install CiviCRM

**K. Configure PHPStorm**

PHPStorm -\> Preferences -\> Language & Frameworks -\> PHP -\> Test Frameworks.

If running into autoloading issues - things to try: add the entire path to phpunit -\> /Applications/MAMP/htdocs/d9civicrm.local/vendor/phpunit/phpunit as a PHP include path in Languages and Frameworks in the PhpStorm settings - hit Apply -\> then check the Test Frameworks page again.

**L. Install Chromedriver**

https://chromedriver.chromium.org/

and start it

```
/usr/local/bin/chromedriver
To check that it's running:
karins-MBP:bin sysadmin$ ps -ax |grep chromedriver
62821 ttys004 0:00.18 chromedriver

```

**M. Run a test!**

Before you can run a test -\> you need to drop all tables and triggers from your database or you'll hit this error (below). Of course make a backup if you have any configs you'd like to keep.

```
1) Drupal\Tests\webform_civicrm\FunctionalJavascript\ContributionDummyTest::testOnePageDonation
RuntimeException: The provided database connection in SIMPLETEST_DB contains CiviCRM tables, use a different database.

```

PS - Note to self: if you run into: `Error : Call to undefined method CRM_Utils_System_UnitTests::parseUrl()`

Go into -\> Run/Debug Configurations and hit Environment Variables and SWITCH OFF -\> Include system environment variables (as one may have included variables specific to CiviCRM Unit Testing)

I'm still working on getting xdebug to work with phpunit test - in the mean time -\> to debug variables within your unit test -\>

```
$result_debug = var_export($contact_result);

```

or

```
throw new \Exception(var_export($api_result, TRUE));

Also handy for local screenshots -> e.g.
    $this->htmlOutputDirectory = '/Applications/MAMP/htdocs/d9civicrm.local/web/sites/default/files/simpletest/';
    $this->createScreenshot($this->htmlOutputDirectory . 'KG.png');

```
> 7 votes

---
Tags: webform-civicrm, drupal-8, drupal-9
---


# Question
Title: Thank You page on contribution form. Print option for the PDF that is emailed as "receipt.pdf"
When completing a contribution, an email can be sent out with an attached PDF called "receipt.pdf". Is it possible to have this PDF printable on the Thank You page? I currently have a sloppy Print Button on my ThankYou.extra.tpl file, but it is not clean because I am using: `$('#crm-main-content-wrapper').before('<div id="print-button"><p><a href="javascript:window.print()" class="btn btn-primary">Print</a></p></div>');` , which is basically printing the entire webpage. I also tried the `&snippet=2` approach in the URL, but that is also too sloppy for the client.

Does anyone know of how to hook into that PDF generation code and spit it out into the ThankYou template?

# Answer
Not tested yet, but can you try calling `/civicrm/contribute/invoice?reset=1&id=<contribution_id>&cid=<contact_id>` in the href instead of `javascript:window.print()`?

Note that the token `<contribution_id>` is the payment id that was created after you submitted the contribution form. `<contact_id>` is the id of the contact to which contribution belongs. Check if you can already get this in the thankyou template variables. More info - https://docs.civicrm.org/dev/en/latest/tools/debugging/#in-smarty-template-files

Also, make sure you've permission to download the invoice. I think civi requires either `access CiviContribute` or `view my invoices`.

UPDATE - For Joomla - The url is - `/index.php?option=com_civicrm&task=civicrm/contribute/invoice&reset=1&id=< contribution_id>&cid=<contact_id>`
> 2 votes

---
Tags: civicontribute, pdf, custom-templates
---


# Question
Title: How do I access drush commands specific to CiviCRM?
I have installed CiviCRM 5.31 on Drupal 8 with the following set of commands according to the official Drupal and CiviCRM documentation:

```
cd /var/www
composer create-project drupal/recommended-project:8.9.8 d8.example.org
cd d8.example.org
composer require drush/drush
vendor/bin/drush site:install
composer config extra.enable-patching true
composer require civicrm/civicrm-asset-plugin:'~1.1'
composer require civicrm/civicrm-{core,packages,drupal-8}:'~5.31'
# now enable CiviCRM module in web UI

```

Now I want to setup scheduled jobs as outlined in CiviCRM's documentation. Running `vendor/bin/drush civicrm-api`, however, leads to the following error:

```
Command "civicrm-api" is not defined.
```

~~As of November 2020, cv is untested for Drupal 8~~, so I would like to use `drush`. What's the "official" way to do this?

---

Software versions

* PHP 7.3.24
* mysql 8.0.22
* Composer 2.0.6
* Drush Commandline Tool 10.3.5
* Drupal 8.9.8
* CiviCRM 5.31.0

# Answer
The readme for cv needs updating. It's now tested pretty well with drupal 8. I would use cv instead.

See also https://lab.civicrm.org/dev/drupal/-/issues/76
> 3 votes

---
Tags: drupal, installation, drupal-8, scheduled-job, drush
---


# Question
Title: Adding an individual to repeating events
I have set up an after school event every monday for six weeks. It's $5 for each session, but if they register for all sessions it's $20 rather than $30.

Currently I have to add the child to all six events individually. Is there some way to add a child to all events in a repetition? Also wondering whats the best way to handle this payment set up? I am unsure how to do it without charging $120 at the moment!

I tried having a look and the registration for multiple events was a requested feature in 2015. Is there any update on this? An extension that could help?

Thanks.

# Answer
> 0 votes
The Multiple Event Registration extension can handle this.

---
Tags: civievent, repeating-events
---


# Question
Title: New D8 / Civi install. First d8 then added Civi. Civi Menus not showig up
I installed D8 first then Civi and it seems like it is working if I manually put the url comonents after the http://focal-civi.domain.org/civicrm/{manually-add} but the menu is not showing up.

Anyone have any hints?

# Answer
> 2 votes
I think I just responded to you on GitLab. From what you described there I think you may need to:

`composer civicrm:publish`

to populate `web/libraries`

# Answer
> 2 votes
This problem was (I think) related to a permission problem with the plug-in not having permissions to copy the libraries from a parent directory to the doc-root directory.

Solved for me. Hope this helps someone else.

# Answer
> 2 votes
Also for me (in addition to directory permissions) is the fact that some distributions use different names for their docroot directory.

Core uses ./web Varbase uses ./docroot OpenSocial uses ./html

This can be accounted for if you add this to the composer.json in the extras section

```
 "civicrm-asset": {
     "path": "***docroot***/libraries/civicrm",
     "url": "/libraries/civicrm"
 },

```

# Answer
> 1 votes
I had something similar on a Backdrop site and it turned out to be caused by the way I had set up the directory structure.

I was trying to get fancy using a symlink and the server was using the symlink as the website's document root, but in the `civicrm.settings.php` I was pointing to the other directory. Changing the settings file to also point to the symlink solved it.

---
Tags: civicrm-home, drupal-8
---


# Question
Title: Can you use VBO to update activities on cases?
I'd like to be able to bulk update the status of activities (that happen to be on a case) from a view.

I can get the status to update but the problem is it loses the Case ID along the way. For example, prior to updating the activity, say it was connected to case 1234. After I run the Bulk Update to change the status of the activity, it sets the case number to 1.

Any idea how to overcome this? (I'm in Drupal 7.)

Update: When I add the CiviCRM Activities: Case ID field to the view I get an error: `SQLSTATE[42S22]: Column not found: 1054 Unknown column 'civicrm_activity.case_id' in 'field list'`

The field should be civicrm\_case\_activity.case\_id but I can't find in the code of CiviCRMEntity where to make that change.

# Answer
> 1 votes
Initially, when I built my view I was missing some relationships - thus the SQL error mentioned above. But even after adding the correct view relationships, the issue still persisted.

I got huge help from @jackrabbithanna on mattermost. He provided code for a civicrm\_customs.module file that will give an "Update Activity Status" VBO action. https://gist.github.com/jackrabbithanna/34016f1e3dac7c1b44a893cc93eed6db

In notes from his chats:

> this provides a separate action, not using "Modify Entity Values" action . . . that sidesteps the entity form irregularities
>
> could do lots of complex things or whatever with API .. but this shows how to make own VBO action to people

---
Tags: activities, drupal-views, civicrm-entity, drupal-7
---


# Question
Title: Dedupe rule to reject record rather than creating new record
i understand that you can use the dedupe rule to identify matching record to merge a new record or to create a new record altogether. Is there a means to reject the new record altogether if a match is not found? For example, if i use this rule in a profile form submission, it will only allow entries that already has a record in the CIVICRM system due to a match but will reject the entry if no match is found. Thanks.

# Answer
> 1 votes
I am not aware of anything in CiviCRM core that would allow you to do so. Depending on your use case you could consider setting up forms that can only be used by authentictaed users.

---
Tags: duplicate-contacts, dedupe-rules
---


# Question
Title: possible bug: when using External ID as matching method, imported contributions can get matched to contacts in the trash--would expect error instead
I have a client whose accounting team has run into the following issue (admittedly an edge case but causes a lot of confusion and troubleshooting time for the team so we want to fix). Following the bug reporting instructions I have replicated this in two demo instances (dmaster and wpmaster) and now want to know if anyone else has experienced this. Here are the conditions/steps. To your knowledge is this a known issue?

* The import matches contributions to contact by External ID
* A given contact has been de-duped and the External ID needed for correct contribution matching has been overwritten by a different External ID
* The contact record with the correct External ID is in the trash
* The contribution import runs without throwing any error message
* The contribution does not appear in the contact record because its External ID does not match, and it DOES appear on the contact record that is in the trash (soft delete).

To summarize: When contributions are imported matching to External ID, expected behavior to get an error message and failed import line if I import a contribution that matches to a contact that is soft-deleted. Instead I get no error message and a successful import matched to a soft-deleted contact.

System info: The client is running Civi 5.31.0 on WP 5.5.3 but since I replicated on dmaster and wpmaster that seems less relevant.

Other relevant info: When using other methods of matching to a contact, the system behaves as expected (i.e., gives an error message and does not import the contribution):

* Email address as matching method gives "No matching Contact found for (\[EMAIL ADDRESS\])"
* Contact ID as matching method gives "Invalid Contact ID: contact\_id 204 is a soft-deleted contact."

# Answer
I suggest you create an issue at https://lab.civicrm.org/dev/core/-/issues

I'd think it should be treated in the same way as if you matched on a contact id that was soft-deleted.

The message you quote appears to be generated from `CRM_Contribute_Import_Parser_Contribution::deprecatedFormatParams()` but given the name, a quick fix to that function to handle external id is not the answer.
> 1 votes

---
Tags: contributions, import, issues, external-id
---


title: exporting custom data structure

text:
# Question
Title: exporting custom data structure
I'm looking for some recommendations. I've inherited a CiviCRM instance with a quite complicated custom data structure, and I want to review and update it. I was wondering if there were any tools or APIs that would help me export or visualize the data schema/fields for different object types?

The best option I can find is exporting all the fields for each type using the Export to CSV function, but that will require manually selecting hundreds of custom fields for each contact type in the field mapping GUI. UUUUggghhh! :-)

I've found the Data Explorer extension (https://civicrm.org/extensions/data-explorer) and am checking if that's a possibility, but that seems to have the same issues as the Exporter -- lots of manual selection.

Can anyone suggest a better way? Thanks!

# Answer
You could start with API Explorer v4:

* Set the `Entity` to `CustomGroup` and `Action` to `get`.
* In the `Chain` section, set `Entity` to `CustomField` and `Action` to `get`. The next box should autopopulate to `{where: [[custom_group_id, =, $id]]}`

Basic example

From there, you can limit the fields returned both for the CustomGroup and the CustomFields and maybe sort them. Once that shows what you want, remove the `Limit` so see all the data.

Example with selected fields

From there, you can copy/paste the generated code to a php file and do what you like with the output.
> 1 votes

# Answer
You could also check out https://doc.symbiotic.coop/dev/civicrm/latest/schema/index.html which is derived using SchemaSpy per the answer here

https://civicrm.stackexchange.com/a/20160/96
> 0 votes

---
Tags: custom-fields, export, data
---


# Question
Title: How to chain api calls i.e. GETFIELD contact for fieldID after doing GET profile on profileID?
I want to join the below api calls-

API 1

```
http://ec2-3-6-40-236.ap-south-1.compute.amazonaws.com/civicrm/sites/all/modules/civicrm/extern/rest.php?entity=Profile&action=get&api_key=userkey&key=sitekey&json={"sequential":1,"profile_id":22}

```

RESULT 1

```
{

"is_error": 0,
"version": 3,
"count": 1,
"values": {
    "custom_64": "",
    "custom_65": "",
    "custom_66": "",
    "custom_46": "",
    "custom_47": "",
    "custom_48": "",
    "custom_62": "",
    "custom_50": "",
    "custom_51": "",
    "custom_63": "",
    "custom_53": "",
    "custom_54": "",
    "custom_55": "",
    "custom_56": "",
    "custom_57": ""
  }
}

```

API 2

```
http://ec2-3-6-40-236.ap-south-1.compute.amazonaws.com/civicrm/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=getfield&api_key=userkey&key=sitekey&json={"name":"custom_62","action":"get"}

```

RESULT 2

```
    {

    "is_error": 0,
    "version": 3,
    "count": 31,
    "values": {
        "id": "62",
        "label": "Relationship with Guardian",
        "headerPattern": "//",
        "title": "Relationship with Guardian",
        "custom_field_id": "62",
        "groupTitle": "Voter Details",
        "data_type": "String",
        "name": "custom_62",
        "type": 2,
        "html_type": "Radio",
        "default_value": null,
        "text_length": "255",
        "options_per_line": "2",
        "custom_group_id": "28",
        "extends": "Individual",
        "is_search_range": "0",
        "extends_entity_column_value": [
            "Voter"
        ],
        "extends_entity_column_id": null,
        "is_view": null,
        "is_multiple": "0",
        "option_group_id": "121",
        "date_format": null,
        "time_format": null,
        "is_required": null,
        "table_name": "civicrm_value_voter_details_28",
        "column_name": "relationship_with_guardian_62",
        "serialize": null,
        "where": "civicrm_value_voter_details_28.relationship_with_guardian_62",
        "extends_table": "civicrm_contact",
        "search_table": "contact_a",
        "pseudoconstant": {
            "optionGroupName": "relationship_with_guardian_20201110084841",
            "optionEditPath": "civicrm/admin/options/relationship_with_guardian_20201110084841"
        }
    }
}

```

I have tried with this api call-

```
http://ec2-3-6-40-236.ap-south-1.compute.amazonaws.com/civicrm/sites/all/modules/civicrm/extern/rest.php?entity=Profile&action=get&api_key=userkey&key=sitekey&json={"sequential":1,"profile_id":22,"api.Contact.getfield":{"name":"$value","action":"get"}}

```

But I got this error :(

```
    {

    "fields": [
        "name"
    ],
    "error_code": "mandatory_missing",
    "entity": "Profile",
    "action": "get",
    "is_error": 1,
    "error_message": "Error in call to Contact_getfield : Mandatory key(s) missing from params array: name"
}

```

Please help.

# Answer
> 2 votes
You probably want the `UFField` entity, not `Profile` ... try:

```
entity=UFField&action=get&api_key=userkey&key=sitekey&json={"sequential":1,"profile_id":22}

```

Then you can chain `getfield`:

```
entity=UFField&action=get&api_key=userkey&key=sitekey&json={"sequential":1,
"uf_group_id":22,
"api.Contact.getfield":{"action":"get","name":"$value.field_name"}}

```

That assumes the custom fields are for Contacts.

---
Tags: contacts, custom-fields, profile
---


# Question
Title: Can you edit webform submission values without invoking payment?
We have a webform that is used for a complex event registration, with all of the registration details stored in the webform and nothing in CiviCRM except the contribution record.

We'd like to be able to edit some of the registration details that users have submitted to the webform, but using the edit submission link leads to the payment part of the submission - requiring that payment details be entered again.

Is there any way to simply edit some of the webform submission values, which aren't connected to the payment, without resubmitting the payment?

# Answer
Here's another possible solution https://www.drupal.org/project/webform\_import
> 0 votes

# Answer
https://www.webwash.net/integrate-webform-and-google-sheets-using-zapier-in-drupal-8/

1. Drupal 8 you can install Webform Remote Handlers module https://www.drupal.org/project/webform\_remote\_handlers Drupal 7 has a similar module (Webform Remote Post) that also works but it is no longer maintained. .
2. Create a Zap in Zapier to connect the results to a Google Sheet.

Now when someone submits a webform, the results are added as a line on the Google Sheet. This allows your non-techy staff to view, edit, sort in a format they are very comfortable with.
> 0 votes

---
Tags: webform-civicrm
---


# Question
Title: How to add a profile with a fieldset that accepts one or more entries for event registrations
I'm not sure that this is possible but here goes:

I have a requirement to collect data from Event Registrants of University Programs that they have undertaken and the years of study they have undertaken. This is not limited to a single entry for the program and each program entry can have 1 or more years of study.

So an Entry could look as follows:

**Program of Study:** Basket Weaving

**Years of Study:**

* 1972
* 1973
* 1974

Ideally I would want to have multiple fieldsets of the Program of Study and Years so the registrant could list one or more programs they undertook and the years they undertook for it.

In that case it would look like:

**Program of Study:** Basket Weaving

**Years of Study:**

* 1972
* 1973
* 1974

**Program of Study:** Advance Basket Weaving

**Years of Study:**

* 1982
* 1983
* 1984

# Answer
One approach would be to use Activities. Set up a custom Activity with the required fields for Program, Year etc

Another approach might be Multiple Record custom field
> 0 votes

---
Tags: drupal, custom-fields, online-registration
---


title: Profile Picture on CIvicrm Form

text:
# Question
Title: Profile Picture on CIvicrm Form
How can I show the Users Profile Picture on a Civicrm Form please (in joomla)?

Thanks a lot, Sri

# Answer
> 2 votes
You can use an API to get the image URL for a contact. For eg -

```
$result = civicrm_api3('Contact', 'getsingle', [
  'return' => ["image_URL"],
  'id' => contact_id,
]);

```

And then copy the value returned by the above API and fed it to the source of image tag in simple HTML code:-

```
<p>
  ......
  ......

  <img src = "$result['image_URL']" />
</p>

```

# Answer
> 2 votes
Just posting so that anyone having a similar question can benefit.

You can login to Civicirm and uder the Support Developer Menu Item look at Developer \> API. Here you can generate your API code including any of the feilds you require. Following is the full PHP code I used to call the profile Display Name, Photograph, Job Title & Phone. Perhaps it is not the most optimized code but it works.. The last Print statements needs to be wrapped withing html tags for formatting. 2nd one is the image path so needs to wrapped within in a image tags src (can not post with html tags here)

```
(PHP starts)
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );
$user = JFactory::getUser();
require_once JPATH_ROOT . '/administrator/components/com_civicrm/helpers/api.php';
CivicrmHelperApi::civiimport('api');

$email = $user->email;

$details = civicrm_api3('Contact', 'getsingle', [
  'return' => ["display_name", "image_URL", "job_title", "phone"],
  'email' => $email,
]);
$profile = array();
$x=0;
foreach ($details as $key => $value) {
    $profile[$x]= "$value";
    $x=$x+1;
}
if ($profile[2]=="") {
    $profile[2]= "/templates/common/images/member-dash-default-photo.jpg";
}

print_r( $profile[1])
echo $profile[2]
print_r( $profile[3])
print_r( $profile[7])
print_r( $profile[9])
(PHP ends)

```

---
Tags: joomla
---


title: Membership tab will not display

text:
# Question
Title: Membership tab will not display
On a multisite with civimember enabled on that domain, the membership tab on the contact summary screen does not show. I have ruled out Contact Layout Editor as a cause by disabling it. I have tried disabling and re-enabling the civimember component and clearing the caches.

I have a valid membership type on that domain too (not that that should matter)

What would be the cause for it not to show?

# Answer
> 2 votes
I would check: https://example.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin%2Fsetting%2Fpreferences%2Fdisplay&reset=1 and see if Membership is 'unchecked'

---
Tags: civimember
---


title: CREATE action for profile missing (v3)?

text:
# Question
Title: CREATE action for profile missing (v3)?
I want to create a profile but I don't see that in the action dropdown. Have attached an image

Please help.

# Answer
> 2 votes
The entity is called UFGroup, and UFField for the fields. The naming is historical. The Profile entity is used to do something equivalent to filling out and submitting a profile form on the front end.

---
Tags: api, profile
---


# Question
Title: Custom Field for CiviCRM Membership not accessible from Drupal Rules module
I'm trying to access a custom field used for **Membership** in CiviCRM from the **Drupal** **Rules** module. But it seems this custom field, ***civicrm-membership:custom-8***, in not accessible from the Drupal Rules modules and it doesn't contain any value.

This is the rule I'm trying to create to **add a CiviCRM Contact to a Group**:

{ "rules\_add\_group\_to\_contacts" : {
"LABEL" : "Add Contacts to Groups",
"PLUGIN" : "reaction rule",
"WEIGHT" : "1",
"OWNER" : "rules",
"REQUIRES" : \[ "devel", "rules\_conditional", "civicrm\_entity", "rules", "civicrm" \],
"ON" : { "**civicrm\_membership\_create**" : \[\] },
"DO" : \[
{ "devel\_debug" : { "value" : \[ "***civicrm-membership:custom-8***" \] } },
{ "CONDITIONAL" : \[
{ "IF" : { "text\_matches" : {
"text" : \[ "***civicrm-membership:custom-8***" \],
"match" : "Stay and Play - Coffee mornings"
}
},
"DO" : \[
{ "civicrm\_entity\_rules\_action\_assign\_contact\_to\_group" : {
"contact" : \[ "civicrm-membership:contact-id-contact" \],
"group\_id" : { "value" : { "18" : "18" } }
}
}
\]

I'm working with **Drupal 7**.

Many thanks in advance for your help.

# Answer
> 1 votes
There are a few things you can try here:

* Go to CiviCRM's **Administer menu \>\> System Settings \>\> CMS Database Integration**. Compare the array there against the one listed in `settings.php`. This array (in `settings.php`) must be updated when you add new custom field groups to CiviCRM (since they add new tables). This is most likely your issue.
* Consider installing the `civicrm_entity` module, which should make your CiviCRM entities available as Drupal entities.
* Consider using CiviRules, which is a CiviCRM-native rules engine. It's very similar to Rules, but it generally understands CiviCRM better.

---
Tags: civimember, drupal-7, rules
---


# Question
Title: Can a CiviRule trigger off a Contribution Custom Field entry?
We have a custom profile "Other Details" that is for Contributions. When someone inputs information into the custom fields, I would like to trigger a Civi Action to do something with that information.

Is there any way to trigger off of that custom table? If I trigger off Contribution is Added, it is too early and has not yet written to the custom table. So I need the trigger to happen off the custom table.

# Answer
> 1 votes
Right now there is no trigger on custom data for a contribution. You could try though with the "contribution is changed" trigger and see if you can pinpoint your custom field/data with the "field value comparison" conditions?

Obviously you are quite welcome to either add the trigger yourself, or fund CiviCooP (or any other partner that is familiar with CiviRules) adding the trigger :-)

---
Tags: civirules
---


# Question
Title: Extension for hierarchical custom fields?
Does anyone have a generic extension for hierarchical custom fields?

For example, we have 'Country', 'State' and 'County' - the value of Country determines what States are valid, and the value of State determines the valid Counties. But that is done with specific coding for those fields. I'm interested in a generic extension that enables reproducing the Country/State/County behaviour without further coding.

The tags feature allows custom hierarchies and has a convenient drag-n-drop interface for creating it ... but the end result is a hierarchy in tags rather than fields.

The focus here is creating hierarchies of data attributes, not an organisational hierarchy of contacts.

# Answer
Yes, I have such an extension \- and so do many others! I think mine is the most functionally advanced, but lacks a UI, or, uh, documentation (oops), and so is unsuitable in most use cases.

If you're interested, I can ask one of my staff members to write some documentation on this today, but broadly:

* This creates two new entities (with full APIs): `FieldLookupGroup` and `FieldLookup`.
* There is one `FieldLookupGroup` for every "lookup" set. `FieldLookup` contains the actual corresponding values.
* Here are some SQL tables of `FieldLookupGroup` from two different clients:

```
+----+----------------+--------------------+----------------+--------------+-------------+-----------------+
| id | field_1_entity | field_1_name       | field_2_entity | field_2_name | lookup_type | lookup_operator |
+----+----------------+--------------------+----------------+--------------+-------------+-----------------+
|  1 | Event          | start_date         | Event          | custom_302   | reverse     | BETWEEN         |
|  2 | Event          | start_date         | Event          | custom_303   | reverse     | BETWEEN         |
|  3 | Activity       | activity_date_time | Activity       | custom_305   | reverse     | BETWEEN         |
|  4 | Activity       | activity_date_time | Activity       | custom_306   | reverse     | BETWEEN         |
|  5 | Participant    | custom_265         | Participant    | custom_307   | reverse     | =               |
|  6 | Participant    | custom_265         | Participant    | custom_308   | reverse     | =               |
+----+----------------+--------------------+----------------+--------------+-------------+-----------------+

```

```
+----+----------------+--------------+----------------+--------------+--------------+-----------------+
| id | field_1_entity | field_1_name | field_2_entity | field_2_name | lookup_type  | lookup_operator |
+----+----------------+--------------+----------------+--------------+--------------+-----------------+
|  1 | Contact        | custom_50    | Contact        | custom_52    | chain-select | =               |
|  2 | Contact        | custom_54    | Contact        | custom_56    | chain-select | =               |
|  3 | Contact        | custom_58    | Contact        | custom_60    | chain-select | =               |
|  4 | Contact        | custom_62    | Contact        | custom_64    | chain-select | =               |
|  5 | Contact        | custom_63    | Contact        | custom_62    | chain-select | =               |
+----+----------------+--------------+----------------+--------------+--------------+-----------------+

```

The first set handles a "reverse" hierarchical lookup - e.g. "given a county, simply fill in the state and country on save". The second set is a "chain-select" and more closely matches what you're looking for.

Here's is a small sample of values from `FieldLookup` for the second client:

```
+----+-----------------------+---------------+-----------------+---------------+
| id | field_lookup_group_id | field_1_value | field_1_value_2 | field_2_value |
+----+-----------------------+---------------+-----------------+---------------+
|  1 |                     1 | 4             | NULL            | 3             |
|  2 |                     1 | 4             | NULL            | 19            |
|  3 |                     1 | 4             | NULL            | 20            |
+----+-----------------------+---------------+-----------------+---------------+

```

Taken together with the table above, this reads: "If a user selects a value of `4` in `custom_50`, then `custom_52` should be limited to the options with values `3`, `19`, or `20`".

`field_1_value_2` is if you use the `BETWEEN` operator - e.g. "if the `start_date` is between `2020-01-01` and 2020-12-31\`, limit the value of the second field to the following options".
> 4 votes

---
Tags: custom-fields, tags
---


# Question
Title: Can I create my own CRM company reselling our version of CivicCRM?
I am looking to create a CRM that I can license to non-profits, that is built on CiviCRM. Is this possible?

# Answer
I think the answer is probably no, but it depends on what the question was.

My reading of section 5 and 6 in the licence as linked by @demerit https://www.gnu.org/licenses/agpl-3.0.en.html means that you can't "license" the code itself, even if you modify it, except by using the Affero license, i.e. you can't charge money for it.

What you can do and what others do is to earn money by providing additional value over and above the code base in some way, typically some version of hosting and/or support.

Conclusion: earning money by selling/renting the code is not allowed, even if you modify it.
> 4 votes

# Answer
I'm not a lawyer, but the gist is that yes you can, but people will expect you to make your modifications available to download.

The license is AGPL 3, which is detailed at https://www.gnu.org/licenses/agpl-3.0.en.html.
> 2 votes

# Answer
Yes; there are many companies that do exactly that. Some market their CRM under the CiviCRM name; others specialize and rebrand (e.g. JVillage sells ShulSuite, a CiviCRM configured for synagogues).
> 1 votes

---
Tags: sales
---


# Question
Title: Use complete address and full county name in mailings
Working on a mailing that includes contacts full address details. And I'm encountering an issue for UK addresses where the county is abbreviated in the same way US states are. I've never seen such 3-char abbreviations used in the UK and it will cause confusion. Omitting the county is not an option either. Sadly the standard address hooks for mailings are limited.

Googling yielded the following page which has code I'm trying to use in a custom Civicrm extension. So far my attempts are failing miserably. I'm not very familiar with PHP, so please excuse and gently correct whatever atrocities I might be committing in the code below.

https://forum.civicrm.org/index.php%3Ftopic=20687.0.html

The extension is meant to provide two new tokens to mailings:

* {contact.province}: prints the State / Province full name (as in {contact.state\_province\_name}). Not the same name in case this brings any conflict with the existing one
* {contact.complete\_address}: prints the full contact's address with the same format set in the label address customization

The article is quite old and uses APIv2, so I've resorted to adapt it to APIv4. In doing so my PHP errors have disappeared but I'm not seeing any results in "Preview as HTML" yet when editing a test mailing.

My hooks code below:

```
// Works, the new hooks show up in the list when editing mailings //
function mailhooks_civicrm_tokens( &$tokens ) {
    $tokens['contact'] = array(
        'contact.province' => 'Province',
        'contact.complete_address' => 'Complete Address',
    );
}
// Not returning anything, the tags are not interpreted at all //
function mailhooks_civicrm_tokenValues( &$values, &$contactIDs ) {
    require_once 'CRM/Utils/Address.php';
    foreach($contactIDs as $id){
        $address = \Civi\Api4\Address::get()
            ->addSelect('street_address', 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3', 'city', 'postal_code', 'state_province_id:label', 'country_id:label')
            ->addWhere('contact_id', '=', $id)
            ->execute();
        $values[$id]['contact.complete_address'] = nl2br(CRM_Utils_Address::format($address[$id]));
        $values[$id]['contact.province'] = $address[$id]["state_province_id:label"];
    }
}

```

The output from the API Explorer (dummy address):

```
(1) [
  {
    "id": 3,
    "street_address": "3 Kings Road",
    "supplemental_address_1": null,
    "supplemental_address_2": null,
    "supplemental_address_3": null,
    "city": "Hitchin",
    "postal_code": "SG5 0AZ",
    "state_province_id:label": "Hertfordshire",
    "country_id:label": "United Kingdom"
  }
]

```

Partial HTML preview:

```
SG5 0AZ, {contact.province}
United Kingdom
{contact.complete_address}

```

Email template:

```
{contact.postal_code}, {contact.province}
{contact.country}
{contact.complete_address}

```

# Answer
It should be like below

```
// Not returning anything, the tags are not interpreted at all //
function mailhooks_civicrm_tokenValues( &$values, &$contactIDs ) {
  foreach($contactIDs as $id){
    $address = \Civi\Api4\Address::get()
      ->addSelect('street_address', 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3', 'city', 'postal_code', 'state_province_id:label', 'country_id:label')
      ->addWhere('contact_id', '=', $id)
      ->execute()
      ->itemAt(0);
    $values[$id]['contact.complete_address'] = nl2br(CRM_Utils_Address::format($address));
    $values[$id]['contact.province'] = $address["state_province_id:label"];
  }
}

```

HTH

Pradeep
> 1 votes

# Answer
This doesn't fix the larger issue (see e.g. https://lab.civicrm.org/dev/core/-/issues/1709) but you can update your database to put the full name in the abbreviation field:

`alter table civicrm_state_province modify column abbreviation varchar(64) DEFAULT NULL;`

`update civicrm_state_province s inner join civicrm_country c ON s.country_id = c.id SET s.abbreviation = s.name WHERE c.iso_code='GB';`

You might need to re-run if new state/provinces are added to GB.
> 1 votes

---
Tags: email, hooks, addresses, apiv4
---


title: Profile sections

text:
# Question
Title: Profile sections
Making some progress with providing mailing users with the opportunity to update their details. We're using custom fields to track completed training (which, date and who trained them).

I've got the custom fields for the training (one entry with multiple fields, 3 per training)

I've got checksum UI working, and can generate the custom URL to point a user to a profile.

I've got a profile which contains address details and the training fields. However, the page presented to the user is just one long list. It would be nice to group the fields in the profile. I don't think there's an easy way to use one page (URL) with multiple profiles each with their own headers.

Google has so far proven unhelpful.

# Answer
> 1 votes
Looks like you are well on the way. The normal way to do this in civi is

* send your contacts an email using a checksum to a profile link (for Edit)
* this should mean the profile pre-fills with their existing info
* they should be able to add new info or update existing info unless that field is set to read only.
* you should be able to use Profile Field type Formatting to add some HTML to give your self subheadings etc
* if you want something more than that, eg collapsible sections then depending on CMS, in Drupal use Webforms, in WP use Caldera forms.

I doubt I answered your question directly but perhaps the 'formatting' field can help you

---
Tags: profile
---


# Question
Title: non technical approach to associate contributions with memberships
Does anyone know of an extension / not technical approach that allows users to manually associate contributions with a membership when they have not been properly associated.

I've seen this happen for various reasons including user and system error. We sometimes write short scripts to fix this by creating entries in the civicrm\_membership\_payment table when it is easy to know what should be linked with what but it would be nice if users could do this on a one to one basis, 1) so they don't have to ask a developer and 2) for those times when it is not obvious what should happen (multiple memberships, contribution types, etc.)

# Answer
> 4 votes
org.civicoop.membershippayment does this and only this.

# Answer
> 3 votes
There is an extension that does that: https://github.com/Project60/org.project60.membership

It can do much more than only connecting memberships and contributions via the UI so make sure that it's not an overkill for your purposes ;)

Unfortunately, there is no coherent documentation so for some features you may want to contact the maintainer (Björn from SYSTOPIA) for info and/or add to the documentation once you know your way around the extension.

---
Tags: civicontribute, civimember
---


# Question
Title: Double opt-in mailing list signup with Caldera Forms CiviCRM
I'm wondering if it's possible to create a "double opt-in" to a mailing list group workflow using Caldera Forms CiviCRM integration. Where the user would enter an email address into a field, then gets sent an email with a link they need to click to confirm they want to be added to the mailing list, and on doing so they're added to the appropriate group in CiviCRM. Essentially the same workflow as using a profile to sign up for a mailing list with the "Enable Double Opt-in for Profile..." settings checked.

Yes, one could just use a profile for this (and have in the past) but would prefer not to deal with the added security risk of enabling external form submissions. The mailing list signup form is in a sidebar widget, not a page, so using a shortcode isn't an option that I'm aware of. Even shorcode widget plugins don't seems to work for this purpose.

So, how would we set up a workflow to use Caldera forms to do this? We have it set up now in such a way that the user inputs their email address, and we use the Contact processor to process their email address and add them to a specific group. This works a treat, just want to explore options for the confirmation email step.

Thoughts? Suggestions?

# Answer
> 3 votes
You can use Jaap Jansmas integration of CiviCRM with the Form Processor for that: Just create a form processor using the action "Mailing Event: Subscribe to mailing list". You can even create simple deduplicating rules using conditions on the actions "Contact: Get Individual by name and email" and "Contact: Create or update Individual". The form processor will then appear as a Caldera Forms processor and you just add your slugs. Never forget to clear the CiviMcRestFace Log in Settings CiviCRM McRestFace Call Log when adding/changing form processors.

Update: Now Jaaps plugin can also be installed from the official Wordpress plugin repo: https://wordpress.org/plugins/cf-civicrm-formprocessor/

# Answer
> 1 votes
Check out https://wordpress.org/plugins/verify-email-for-caldera-forms/ to do that double opt in step.

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


# Question
Title: Has anyone run into scheduled jobs drifting on Centos7?
We're only seeing this for projects on one specific server (running Centos7; using chrony; PHP 5.6.21). We are NOT seeing this for projects on our other server (running Centos6; using ntpd); Working theory is that we should go to ntpd on Centos7. Has anyone else run into this?

**The problem:** a Scheduled Job configured to run daily - runs **exactly every 25h:**

```
2016-05-21 15:04:51
2016-05-20 14:04:17
2016-05-19 13:04:41

```

**EDIT:** system crons (Drupal and CiviCRM) run hourly - on 03 and 04, respectively - and I've confirmed those jobs that are scheduled to run 'always' indeed execute every hour.

# Answer
I don't know if this is the case here, and it seems more regular than my experience, but my coworkers and I have seen cron jobs walk fairly regularly. (We're more commonly using Ubuntu 14.04 or 12.04, however.)

The usual issue I see is the following with a daily scheduled job:

* cron run starts at 1:00:00
* there are a bunch of things to do, so it gets to the daily job at 1:00:20
* the next day at 1:00:00, cron runs again
* there's less to do, so it gets to the daily scheduled job at 1:00:10
* being "daily", the scheduled job checks to make sure its previous run was more than one day ago, and that check fails since it was 23 hours, 59 minutes, 50 seconds ago
* the scheduled job executes the next time cron runs

In my experience, that would normally make the scheduled job walk one cron interval (usually 5, 6, 10, or 15 minutes) rather than an entire hour. However, if you only have the cron job running hourly, that would explain your phenomenon exactly.

Unfortunately, there's no way to guarantee that a scheduled job will get run at a precise time each day unless you have a separate cron job to run the single scheduled job. However, reducing the cron interval will mean that when the schedule job does walk, it'll take smaller steps.

*(Side note: this situation is why I always have the scheduled reminders job run hourly rather than daily. Otherwise, the scheduled job might walk all the way to 11:00 pm, potentially reminding people about the next day's event after the recipients have gone to bed.)*

**UPDATE:** As Karin describes below, this was addressed in 4.6.3, so the later 4.6.x releases all fix this. However, some changes introduced in 4.7 had the result of undoing this. The relevant issue is CRM-18671 for describing what's going on.
> 3 votes

# Answer
This extension might solve this issue: Cron Plus
> 2 votes

# Answer
This may actually not be related to Centos7 vs Centos6 but due to the fact that the project in question is still on 4.4 LTS - Looks like this was addressed in 4.6.3: https://issues.civicrm.org/jira/browse/CRM-16276 \- thanks @Allan Shaw!
> 1 votes

---
Tags: cron-job, cron, webserver
---


# Question
Title: Email-to-activity processing: how to ignore cc
Autofiling inbound emails as activities via EmailProcessor is a really nice feature. However for some CivCRM users it would be nice to have (always and system-wide) only filed activities for the FROM and TO contacts. Is there a way have CC addresses ignored?

# Answer
You can ALMOST do it with hook\_civicrm\_emailProcessorContact, but you don't know at that point which ones are cc's.

But you might be able to do it with hook\_civicrm\_emailProcessor because there you know which are cc's, except you only have their email not the contact\_id. So I admit this is awkward but you could do something like:

1. For each of the cc's, look up the contact id from the email address the same way the email processor does - `CRM_Contact_BAO_Contact::matchContactOnEmail($email, 'Individual')->contact_id`
2. The activity\_id should be in the $result param in the hook.
3. Delete the corresponding entry in civicrm\_activity\_contact. (If they were listed both as a To and a Cc you might need to get a little fancier.)
> 1 votes

---
Tags: email, activities
---


# Question
Title: How can I get at the Email address of a Contact Reference? CiviMail and Tokens question!
It's straight forward to insert the Name of a Contact Reference (custom field) in CiviMail using Tokens. Does anyone know of a way to get at the Email address belonging to that Contact Reference?

# Answer
> 1 votes
Maybe the "Related Token Extension" does the trick? Even if not, it may be better to build up on an existing extension that pulls token from related contacts instead of building a new extension from the scratch.

Another example for such an extension ist the "Additional Token" extension, I am pretty sure I have seen others...

---
Tags: civimail, tokens
---


# Question
Title: utfmb4 conversion gone wrong - Some columns in the databse have utf8mb4_general_ci others utf8mb4_unicode_ci causing and Illegal mix of collations
I've recently run utf8mb conversion (through API explorer) on civi 5.28. Everything seemed OK, but now whenever I try to access events dashboard I get **Illegal mix of collations (utf8mb4\_general\_ci,IMPLICIT) and (utf8mb4\_unicode\_ci,IMPLICIT)** db error. And indeed when run the sql query to count columns by collations I get:

```
|2 | utf8mb4_bin|
|159 | utf8mb4_general_ci|
|692 | utf8mb4_unicode_ci|
|24 | utf8_general_ci|
|4 | utf8_unicode_ci|

```

The following query

```
show variables like 'collat%';

```

gives me

```
collation_connection    utf8mb4_unicode_ci
collation_database  utf8mb4_unicode_ci
collation_server    latin1_swedish_ci

```

Why are some columns utf8mb4\_general\_ci and others utf8mb4\_unicode\_ci? How to I resolve this?

# Answer
> 1 votes
@mattwire helped me on chat.civicrm.org to identify the problem.

It was caused by the drupal script I used to convert drupal tables (to the wrong collation), and that script included the tables from civicrm which were listed in the drupal settings.php

I've rerun the civicrm api conversion and the drupal script properly and now everything works.

---
Tags: database, php, mysql, core
---


# Question
Title: How can I restrict a users ability to edit a custom field
I am trying to restrict a set of users to edit specific fields. The fields I want to restrict are all custom fields (but it would also be useful to restrict edit privileges on standard address fields).

I am going round in circles on Wordpress user accounts/permissions, ACL roles, profiles, groups etc.

So essentially i want some fields editable, others view only.

# Answer
Unfortunately I don't think this is possible through the UI. As far as I know the ACLs for custom fields only have a combined view/edit permission - it's both, or nothing. Similarly I don't think it's possible to hide address data out of the box.

If you wanted to stop them viewing the custom fields altogether, you could turn off their access to custom data, then create ACLs for any custom fields you *do* want them to see:

1. Assign the users to a particular role within WordPress. By users, I mean the WordPress users - so the usernames they use to log into the website.
2. Go to WordPress Access Control and make sure they *don't* have the 'access all custom data' permission
3. Create a new group in Civi with the type 'Access Control'. Add the Civi record of all the above users to it (Each user login should have an associated record in Civi)
4. Go to 'Users and Permissions' -\> 'Access Control' -\> 'Manage Roles' and create a new role. For example, we have 'Office users', 'Home users' etc.
5. Go to 'Access Control' -\> 'Assign Users to Roles' and assign the group from #3 to the role in #4. You could add multiple groups to this role if you wanted.
6. Go to 'Access Control' -\> 'Manage ACLs' and add an ACL. Use the role from #4, the Operation 'Edit', the type of data 'A set of custom data fields', then select the appropriate custom fields.
7. Remember that these users will only be able to access the custom fields that you specifically allow them to on this screen. So you may need to create multiple ACLs, and create new ACLs when you create new custom fields in future.

It's probably worth playing around with ACLs just to check there's no way to set a view-only permission, just in case the functionality is there but the UI hasn't caught up.

It might be possible using permission hooks, though - I'll leave that for someone better informed than me.
> 4 votes

# Answer
check out this documentation: http://book.civicrm.org/user/current/initial-set-up/permissions-and-access-control/

If you want to restrict edit privileges of standard address field, you might have to set the fields in a profile
> 0 votes

# Answer
There is a pull request which enables ACLs for custom fields to respect View only permission: https://github.com/civicrm/civicrm-core/pull/15347
> 0 votes

---
Tags: permissions
---


# Question
Title: Howto Edit the billing name on a billing address
CiviCRM 5.16.3

In the billing address section on contact view, we can see a full Name and Address. When we edit or quick edit the contact, the full name is not seen or editable. How can we edit it?

Note: as to how that name is getting there, my current guess is via webform civicrm or an extension but I need to verify. I believe what is happening is someone is using another persons credit card to pay, and it's updating the billing address with that persons name. Then, when a receipt goes out in the future, some of our templates are pulling that instead of the billing name/address used in the checkout form (I think..)

# Answer
> 1 votes
This can be done via settings at civicrm/admin/setting/preferences/address?reset=1

Look for the field = Address Name

in the section Address Editing

it can also be removed from display at same screen, look for Address Display and remove

{contact.address\_name}

---
Tags: addresses
---


# Question
Title: Is there an out of the box way to put mailto: links on the emails in the contact search results?
I customized the contact search result view by using a profile (without the state, but with phone and email) and made this profile the default view. I am looking for a way to make the emails clickable (mailto) so my coworkers can just click this and use their mailclient to do a straight forward mail. (either that or a mail button, any solution would be appreciated.

tia

# Answer
> 1 votes
Yes, its possible using hook\_civicrm\_searchColumns to rewrite the email row to include mailto

---
Tags: search-results
---


# Question
Title: "Your postal code is incomplete" on Spark signup page
I'm trying to sign up for Spark, using the link found here: https://civicrm.org/spark I've entered all my information and keep getting an error that says "Your postal code is incomplete". There are two places to put in your zip code on this form, I have filled them both in. I have tried the zip format and the zip+4 format. Getting the error each time. I get the error whether I let my browser do the autofill settings or not. Ready and willing subscriber here, being kept from becoming your customer by this frustrating problem. Not a great start, this does not exactly inspire confidence that I want to use this (will my subscribers have the same problem?).

# Answer
Just double-checking: when filling in the form, after typing the credit card number, do you see the postcode/zip field?

The payment processor (Stripe) displays a different field depending on the country (numeric ZIP for the US, alphanumeric for Canada, etc). I have to admit it's a bit confusing. I will double-check if we can do something about it.

If the issue persists, please do not hesitate to reach out by email at spark@civicrm.org.
> 2 votes

---
Tags: civicrm-spark, postcode
---