# Question
Title: Make Member Directory with SearchKit / FormBuilder which does not show all members
I have built a Member Directory using SearchKit with a SearchKit Table and filtered on the connected Form using the Contact Sort Name, which creates a user search box. I cannot see a way to prevent the user just hitting the "Search" button to yield the full list of members - I want to constrain users to only see records that match an entered search term. Is this possible? Selecting "Required" for the text filter does not compel the user to enter text in the Search field. Additionally, and perhaps an alternative, it would be nice to be able to force the Search results to limit to a maximum number of records, but I cannot see how to force such a limit either.

# Answer
> 2 votes
There should be an option available on the search kit display setting to auto-run or use the Search button. Selecting 'Auto-run' should load results automatically but with button the user will need to hit the button to display the results

HTH

Pradeep

---
Tags: searchkit, directory, formbuilder
---


# Question
Title: Create automation to add membership for all in group
I'm looking for a way to have Civi take all the people in a group and sign them up for a membership of a specific type, then remove them from the group. My hunch is that this should be done in scheduled jobs, but I have 0 familiarity with API and I have no idea how to write it. For background, I'm using the integration with Ninja Forms, which doesn't appear to have a way to create or update memberships automatically. I can get it to add someone to a group after filling out a form, so I'm hoping there's a way to automate the workflow within Civi to get them from the group to the membership.

# Answer
Welcome to CiviCRM SE.

You can use Civi Rules extension, and create a rule with

1. trigger \> 'Contact is Added to the Group'
2. Condition \> Group = ABC
3. Action \> Add membership

HTH

Pradeep
> 3 votes

---
Tags: civimember, scheduled-job
---


# Question
Title: Installing, enabling and disabling extensions returns "is not of type String"
I have multiple issues with my extensions in CiviCRM version 5.53.0 using WordPress. Note that the database was migrated from a previous Drupal installation.

Whenever I install, enable or disable an extension, I get the following stack trace:

```
0   CRM_Core_DAO::composeQuery('UPDATE `civicrm_…', Array, true)    /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php:1619
1   CRM_Core_DAO::executeQuery('UPDATE `civicrm_…', Array)  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/CustomOption.php:238
2   CRM_Core_BAO_CustomOption::updateValue(868, 'table')    /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/OptionValue.php:145
3   CRM_Core_BAO_OptionValue::add(Array)    /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/OptionValue.php:34
4   CRM_Core_BAO_OptionValue::create(Array) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/Traits/DAOActionTrait.php:170
5   Civi\Api4\Generic\DAOUpdateAction->write(Array) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/Traits/DAOActionTrait.php:141
6   Civi\Api4\Generic\DAOUpdateAction->writeObjects(Array)  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/DAOUpdateAction.php:31
7   Civi\Api4\Generic\DAOUpdateAction->updateRecords(Array) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/AbstractUpdateAction.php:93
8   Civi\Api4\Generic\AbstractUpdateAction->_run(Object(Civi\Api4\Generic\Result))  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/Civi/Api4/Provider/ActionObjectProvider.php:69
9   Civi\Api4\Provider\ActionObjectProvider->invoke(Object(Civi\Api4\Generic\DAOUpdateAction))  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php:149
10  Civi\API\Kernel->runRequest(Object(Civi\Api4\Generic\DAOUpdateAction))  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/AbstractAction.php:234
11  Civi\Api4\Generic\AbstractAction->execute() /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/api/api.php:85
12  civicrm_api4('OptionValue', 'update', Array)    /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/ManagedEntities.php:257
13  CRM_Core_ManagedEntities->updateExistingEntity(Array)   /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/ManagedEntities.php:144
14  CRM_Core_ManagedEntities->reconcileEntities(Array)  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/ManagedEntities.php:112
15  CRM_Core_ManagedEntities->reconcile()   /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:417
16  CRM_Core_Invoke::rebuildMenuAndCaches(true) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager.php:425
17  CRM_Extension_Manager->disable(Array)   /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Extensions.php:197
18  CRM_Admin_Form_Extensions->postProcess()    /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php:573
19  CRM_Core_Form->mainProcess()    /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php:144
20  CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Extensions), 'next', 'Next')   /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php:43
21  CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Extensions), 'next')  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php:203
22  HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Extensions), 'next')    /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php:103
23  HTML_QuickForm_Page->handle('next') /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:355
24  CRM_Core_Controller->run()  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php:334
25  CRM_Core_Page_Basic->edit(64, null) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php:140
26  CRM_Core_Page_Basic->run()  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Page/Extensions.php:105
27  CRM_Admin_Page_Extensions->run(Array, null) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:319
28  CRM_Core_Invoke::runItem(Array) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69
29  CRM_Core_Invoke::_invoke(Array) /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36
30  CRM_Core_Invoke::invoke(Array)  /home/WEBSITE/public_html/wp-content/plugins/civicrm/civicrm.php:1199
31  CiviCRM_For_WordPress->invoke('')   /home/WEBSITE/public_html/wp-includes/class-wp-hook.php:308
32  WP_Hook->apply_filters('', Array)   /home/WEBSITE/public_html/wp-includes/class-wp-hook.php:332
33  WP_Hook->do_action(Array)   /home/WEBSITE/public_html/wp-includes/plugin.php:517
34  do_action('toplevel_page_Ci…')  /home/WEBSITE/public_html/wp-admin/admin.php:259
35  {main}

```

The error message below the stack trace is simply "is not of type String". The extension is installed, activated or disabled correctly, but since I am having other issues with these extensions, I wanted to bring this up and see if there is an underlying issue.

# Answer
As it turns out, this was related to faulty entries in `civicrm_managed`. I deleted the entries and reinstalled the related extension (which was SearchKit in my case), the extensions now update correctly and no errors appear when modifying them.
> 3 votes

---
Tags: upgrade
---


# Question
Title: Creating a profile for updating multiple membership records
I have read how to do a batch update of multiple membership records. This involves having already created a profile. I have tried creating a membership profile but when i try to do the update multiple records after my advanced search it says i need a profile. My profile record must be wrong.

Can anyone point me to a idiots guide to creating profiles that will show me how to create for a batch update.

thanks Dave

# Answer
If you use Advanced Search, you're searching for contacts, not memberships — and you can't use a memberships profile to update contacts.

But if you use Memberships - Find Membership to search for memberships, you should be able to select your memberships profile to update them.
> 1 votes

---
Tags: civimember, profile, batches, multiple-records
---


# Question
Title: Search Kit: How can I sort a rewritten column by the new output (it's sorted by the overwritten content)?
I've learned here How can I change the date format in a Search Kit result?, that I can change the output of a date (in my case birth\_date) through rewrite-option and smarty. The reason why is, that I just want to sort the date by day and month to show next birthdays in ascending order.

So I tried `{"[birth_date]"|date_format:"%d.%m."}`

Unfortunately, the column is still sorted including the year of birth, i.e. according to the actual content and not according to the overwriting. Is there an option to manage this?

# Answer
A workaround may be adding the 'Birth Date' field three times to the search and use functions for two (i.e one set to 'partial date' - days and the other to month only) and the full date for the third column.

You don't need to show the first two in your display but can still use them for sorting.

== Edit - add screenshot ==
> 2 votes

---
Tags: searchkit
---


# Question
Title: How to manage a Mentoring-System with CiviCRM
I would like to organize a mentoring-platform where mentees/mentors can register via a website. Mentees can get assigned to mentors in geographical proximity by an organizer of that region. Mentors see a simple overview of their mentees with restricted view of details. Organizers in turn can manage, supervise and assign people in their (zip-code)region.

I'm looking for some tool that can support that use-case. I was thinking about a FLOSS "customer relationship management" tool and was directed to CiviCRM. Can CiviCRM provide what I'm looking for natively? Is there some extension that would serve? How should I go about this problem? Is CiviCRM the right tool for that purpose?

Any pointers are appreciated.

# Answer
> 2 votes
There is a CiviCRM Showcase "Student Support" that shows how to solve a similar problem: https://docs.crm-showcases.org/docs/civicrm-student-support/

It uses native Relationships to model the "mentor-mentee" relationship, uses the extension "form processor" to build forms for registration and makes reports using the extension "data processor"

Furthermore:

The CiviRules functionality can be used to automatically assign the organizer upon registration, with scheduling Actions for assigning a mentor to a mentee.

# Answer
> 1 votes
Welcome to SE!

Yes, CiviCRM would be a good fit for your mentoring system although it will take some configuring to do what you want.

There are lots of options for tackling this. Initial thoughts would be to create 3 contact subtypes for Mentee, Mentor, Organizer and build lists/displays/forms using SearchKit and FormBuilder. These are relatively new (and still rapidly evolving) features in Civi.

Unless you like a challenge(!), you might want to find someone to help you get started - see https://civicrm.org/partners-contributors

---
Tags: contacts, groups, permissions, relationships, acl
---


# Question
Title: Include Financial Type in Payment Processor Transaction Information
The PayflowPro payment processor extension for CiviCRM attempts to include the financial type by including the following item in the data that is sent to the PayflowPro API. Although, I had to modify this a bit so that the financial type is still sent to PayflowPro when a user signs up for an event.

```
$payflow_query_array = [
...
      'COMMENT1' => urlencode($params['contributionType_accounting_code']),
...
    ];

```

Do the other payment processor extensions for Civi do this - send the financial type to the payment processor dashboard? Specifically, the big ones: Stripe, Authorize.NET, and IATS?

# Answer
> 2 votes
Not all payment processor sends financial type or other details related to accounting to the Payment gateway from Civi. But each payment processor allows altering the params that are sent to the payment gateway via `hook_civicrm_alterPaymentProcessorParams` hook.

---
Tags: civicontribute, contributions, payment-processor, financial-types
---


# Question
Title: SearchKit: return a value from one field based on the value in another?
I am building a Membership Directory using SearchKit and FormBuilder. The Directory includes details of statutory license to practice (regulator + licence number, combined in SearchKit as a string) (values stored in two custom fields of the Individual Contact record). I want to hide these details if the Individual is also marked Practice Status "Retired" (also stored in the Individual Contact Record). How can one construct a SearchKit query (or perhaps alternatively conditionally change the combined field value, which is passed to the public Form) to hide the combined value if the Practice Status = "Retired"?

# Answer
If you are on CiviCRM \>= 5.47.x, you can use smarty conditions in the rewrite section of the field on display searches.

\[!\[enter image description here\]\[1\]\]\[1\]

the expression would be something like below

```
{if "[Contact.Details_ccc.Practice_Status]” neq “Retired”}[CONCAT_WS_COMBINED_TEXT_REG_LIC_NUMBER]{else}{/if}

```

**Note**: Replace the field name in the square brackets(\[\]) with actual names.

HTH

Pradeep \[1\]: https://i.stack.imgur.com/TzzqY.png
> 3 votes

---
Tags: searchkit, directory
---


# Question
Title: Is it possible to open a case (of a certain type) as the action of a CiviRule?
I'm trying to write a CiviRule with the trigger "Custom Data on Individual Changed" and the linked conditions "Contact Custom Field Changed is one of" AND "Field Value Comparison". Using the simple linked action "Add Tag to Contact" I've been able to verify that this performs as expected. However, when I instead use the linked action "Create case activity" (see details below) nothing appears to happen. I'm trying to configure this rule such that a case of a particular type (Volunteer Recruitment - befriending) is created when the rule is triggered. (To be clear, this case type has already been set up in the system.) Any suggestions would be greatly appreciated. Thanks.

# Answer
> 1 votes
The class for adding an activity to a case is *CRM\_CivirulesActions\_Activity\_AddToCase* (and so will be in folder ...../civirules/CRM/CivirulesActions/Activity). The actual processing of the action takes place in the function *executeApiAction*, I would start debugging in that function and the *processAction* function in the parent class.

There is a CiviCRM Developer Guide if you have not found it already: https://docs.civicrm.org/dev/en/latest/

---
Tags: civirules
---


# Question
Title: SearchKit: identify current Memberships where last recurring payment or instalment is too old
I would like to construct a query in SearchKit - if it is possible - that answers the question: "Find active (Current, New) Memberships where Contributions recur monthly and the last Contribution was more than one month ago.", and separately, "Find active Memberships where Contributions recur annually and the last Contribution was more than one year ago". This would be enormously helpful in trapping situations where recurring payments have failed for a variety of reasons. Before SearchKit, there was no hope (it seems) of finding these Memberships without a large set of search strategies, but with SK, the possibility of a simple solution looks tantalisingly close...

# Answer
> 1 votes
Are you dealing with failed recurring contributions or simply contributions that don't exist?

If it's failed recurring contributions, you can do:

* Memberships
* Where Recurring Contribution is not empty and Status is one of Current, New
* Without Membership Recurring Contribution where Number of Failures is greater than 0

If it's that contributions don't exist, you could do:

* Contacts
* with Memberships where Recurring Contribution is not empty and Status is one of Current, New
* without Contributions where Recurring Contribution is not empty, date in range last 30 days, and Status = Completed

This assumes your contacts don't have other recurring contributions.

---
Tags: recurring-contributions, searchkit
---


title: Looking for a CiviCRM SAAS environment

text:
# Question
Title: Looking for a CiviCRM SAAS environment
Are there any Civicrm SAAS providers? I don't want to maintain a CiviCRM installation, just be a user. I currently host a client's installation and no longer have capacity to maintain it. Would prefer to pay for someone else to maintain and just allow client to input data, edit data and send mailings.

# Answer
If your client's needs are fairly simple then Spark may suit them.

There is a listing of hosting providers here which represents a wide range of options:

* Some offer a hosting environment with CiviCRM installed and you manage the rest.
* Others provide a predefined set of extensions/configurations which may or may not suit.
* Others only provide hosting as part of a package of other services.
* Avoid anyone offering an 'enhanced' (lock-in) version.

You may need to contact a few to understand what is really on offer and what suits you.
> 3 votes

# Answer
I have direct experience of just two, as a volunteer for a small charity, and only for a short time: Spark and CiviHosting. They are distinct offerings: the former is more expensive but easier for a non-techie to cope with during the set-up phase, the latter is less expensive but harder for a non-techie to cope with during the set-up phase. The former imposes more constraints (e.g., in terms of selection of extensions), the latter imposes fewer constraints. I would heartily recommend both for their general helpfulness and speedy responses.
> 1 votes

---
Tags: hosting-providers
---


title: Multilingual Contribution Page

text:
# Question
Title: Multilingual Contribution Page
I managed to install CiviCRM with multiple language support (English, Traditional Chinese, and Simplified Chinese). I can input selected fields in the 3 languages in the contribution page. However, the URL generated is something like this:

http://xxx.xxxx.com/civicrm/contribute/transact/?reset=1&id=2

It only shows English language. How can I display other two languages?

I saw a similar question asked back in 2019, but still unanswered. Great thanks for your help.

# Answer
Thank you for your answer. I've found that respective language page can be displayed by adding a string “&lcMessages = zh\_CN" where "zh\_CN" is the language code.

The pages of the 3 languages can now be accessed by :

Simplified Chinese: http://xxx.xxx.xxx/civicrm/contribute/transact/?reset=1&id=2&lcMessages=zh\_CN

Traditional Chinse: http://xxx.xxx.xxx/civicrm/contribute/transact/?reset=1&id=2&lcMessages=zh\_TW

English: http://xxx.xxx.xxx/civicrm/contribute/transact/?reset=1&id=2&lcMessages=en\_US
> 2 votes

# Answer
CiviCRM picks up the language that is being used by the host CMS. For example, if you are using Drupal in Traditional Chinese then the form in CiviCRM should load in Traditional Chinese as well.

I have not personally used this but there is a Language Switcher extension (https://civicrm.org/blog/ayduns/language-switcher) that might give you more what you are looking for.
> 1 votes

---
Tags: multilingual
---


title: Deny access to a set of records

text:
# Question
Title: Deny access to a set of records
I've been battering my head against this on-and-off for months now.

Why isn't there a simple way to deny access to a specific set of records?

We use a *lot* of groups, so manually assigning each group to an ACL isn't feasible. The ideal solution would be to put all restricted records in a group, give everyone access to all groups, then deny them access to the restricted records group. After that, we could use the excellent Related Permissions module to control access to individual records. But there isn't a "deny" in Civi's ACLs.

I suspect the aclGroup hook might be one I need (https://docs.civicrm.org/dev/en/latest/hooks/hook\_civicrm\_aclGroup/) but the documentation, as for much of Civi, is minimal. In the example section of that page it has a link "Check HRD module" which is a 404. I searched github and found 1 codebase that used the hook, but in too complex a manner for me to be able to get anything from it. There are apparently NO extensions using this hook in lab.civicrm.org

Any pointers about this question would be gratefully received. And not just a link to https://civicrm.org/blog/lobo/implementing-a-custom-acl-system-in-civicrm. I've read that. It hasn't helped much.

I've never known a code base that is as difficult to get into as CiviCRM - given that I've hacked on Emacs plugins, and the first patch I ever submitted was for a Drupal Views extension. I'm only a part-time programmer, so I need to be able to work my way in, not feel like I'll have to learn how most of the CiviCRM codebase works before I can do anything. So little good documentation, so many links that are broken or out-of-date, web searches that bring up results for older versions of CiviCRM. It's very frustrating, especially as it strikes me that it shouldn't be that difficult a thing to implement. I know it's open source, and I'd be happy to help with documentation, and with code, but it's too difficult to get a first foothold.

# Answer
Deny ACLs have been a long-standing request, but one that no one has contributed or offered to fund. You can see the open issue.

There's a bit of a tragedy of the commons that many developers, rather than develop the full feature, simply use a hook to meet their immediate need.

To help you do that - the `hook_civicrm_aclGroup` is probably the wrong hook, though you can view its use in the multisite extension. You probably want `hook_civicrm_aclWhereClause`. A simpler example of this can be found in the View My Event Participants extension, and a more complex version in the Related Permissions extension.

Edited to add: Here's an (anonymized) code example from a client-specific extension I wrote which is simpler still, but is a more limited use case. `CRM_Myclientpermissions_Utils::getVipContactsIds();` returns a list of Contact IDs that only people with the `Access VIP Contacts` permission are allowed to see.

```
function myclientpermissions_civicrm_aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
  // If the person doesn't have the "Edit All Contacts" permission, this is called, restricting access to the VIP groups.
  if (!$contactID) {
    return;
  }
  // If the person has the "View VIP contacts" permission, skip this.
  if (CRM_Core_Permission::check('access vip contacts')) {
    return;
  }
  // The calling function will apply a "0" for no access if the WHERE statement is empty.
  // So let's not inadvertently create a WHERE when no access is applicable.
  // That is, View Only contacts can't see anyone.
  if (!$where) {
    return;
  }

  $vipIds = CRM_Myclientpermissions_Utils::getVipContactsIds();
  $vips = implode(",", $vipIds);
  $where .= ($where ? ' AND ' : '') . " contact_a.id NOT IN ($vips)";
}

```
> 1 votes

---
Tags: developer, acl
---


# Question
Title: Enable a PA to manage membership on behalf of their manager(s)
I want to enable the Personal Assistant of an Individual Member (or multiple Members, but not all employees of the same organisation) to be able to set up membership (and pay renewals) on their behalf (without signing in, in their name). I think this might be achieved using permissioned Relationships and the extension "Relationship Permissions as ACL", but I'm surprised I can't find evidence of this requirement amongst other users. How might this work?

# Answer
I've implemented a variation on this a couple of times, and found that requirements are wildly different from organization to organization. Combined with the fact that most CiviCRM orgs are not using CiviMember, that's why there's no general implementation.

There's two parts to this: Initial signup, and sending renewal notifications to the PA.

#### Initial signup

##### With Drupal and Webform-CiviCRM

Webform-CiviCRM makes it easy to set up a membership for one contact while registering as another.

##### FormBuilder

FormBuilder isn't there yet. It can almost handle this situation for free memberships (a 3-line patch adds membersip support) but it's still a ways from handling payments.

For one of my WordPress clients, we handle renewals this way. I created a two-page form - the first is FormBuilder, then we use the post-submit URL to redirect a user to the payment page. However, their renewals are all with logged-in users. It's currently unclear if doing this while not logged in is possible.

##### Caldera Forms/Ninja Forms

If you're on WordPress, you can also explore the community fork of Caldera Forms, or Ninja Forms, both of which are likely to support your scenario (though collecting payment requires a paid plugin with Ninja Forms).

##### Form Processor

If you're on Joomla, or these other scenarios are unworkable - there's a final answer, but it's much more work to set up. Create a form in the tool of your choice (e.g. FormStack, SurveyMonkey) and on submission, fire a webhook to an endpoint created with the Form Processor extension. My WP client using FormBuilder for renewals uses WPForms + Form Processor for the initial signup.

#### Renewal notifications/payment

For handling notifications to the PA, I recommend using CiviRules and Email API to create a rule with the action "send an email to a related contact" when the membership is almost up. If you use invoicing, my altinvoice extension will allow sending invoices to additional contacts based on a relationship setting.
> 2 votes

---
Tags: civimember, permissions, relationships
---


# Question
Title: PHP Cannot Find File From Vendor Directory
After upgrading to PHP 8 (8.0.25) my CiviCRM install fails to be able to find /var/www/user/web/vendor/civicrm/civicrm-core/install/langs.php. This happens whenever I try and go to a /admin\* page in Drupal.

There is an error in the Drupal Watchdog log and a warning given by PHP.

The PHP warning is "Warning: require(/var/www/user/web/vendor/civicrm/civicrm-core/install/langs.php): Failed to open stream: No such file or directory in /var/www/user/vendor/civicrm/civicrm-core/setup/plugins/init/AvailableLangs.civi-setup.php on line 22."

The complete error message from Drupal Watchdog is - "Failed opening required ''/var/www/user/web/vendor/civicrm/civicrm-core/install/langs.php'' (include\_path=''.:/var/www/user/web/vendor/civicrm/civicrm-core:/var/www/user'"

I have Drupal 9.3.6 and CiviCRM 5.55.2.

Summary Fields and NCN Civirules Actions for Zoom need to be updated to work with PHP 8 but they are both disabled.

I have verified that the file (langs.php) does exists at the location shown in the error message. I have also made sure that the file is not blank.

Any help is greatly appreciated.

Thanks!

# Answer
Since you've confirmed the file exists (for future readers - the `vendor` folder can be inside the `web` folder or as a sibling - make sure you get it right!) this has to be a file permission user.

* Determine which user your PHP runs as.
* Recursively change the owner and permissions on the `vendor/civicrm` folder to give that user access.

File ownership and permissions varies by operating system and is out of scope for this Stack Exchange, but there are many articles on the topic online.

There are several ways to determine what user your PHP is running under, and it varies by OS and hosting company. However, copying the permissions and owners of the other Drupal files should give you a workable configuration.
> 2 votes

---
Tags: drupal, php, php8
---


# Question
Title: Contribution page 'Other Amount' is added to default amount
On contribution page on my site, I entered 'other amount': $10. However, I did not select 'Other Amount' radio box. The default radio box ($25) stays selected. When the payment is submitted it sums the default and other amount and charges $35 rather than just the intended $10.

I'm not sure if this is the intended or not, but it seems unintuitive for an end-user. Any way to indicate that if 'other amount' is populated, to disregard the other radio boxes?

# Answer
> 1 votes
Are you using a price set? I believe that if you set the amounts directly in the Contribution Page settings, then when you click on the Other Amount field, the Other Amount radio button is selected, doing what you expect. If you aren't using a price set and this isn't working, please provide details on your version and CMS.

But if you're using a price set, then this doesn't work. That's because the Other Amount field isn't formally a separate other amount field in a price set - it's just a numeric price field with a $1 amount. I think it might make sense to make it possible to add a formal Other Amount field to price sets or otherwise figure out a way to make this work better, but that would require someone to take this on (or fund an expert to take it on).

# Answer
> 1 votes
I agree with Lars - the behavior you describe should be the default behavior on a contribution page without price sets, and it probably is worth comparing with a demo site to confirm the behavior.

If you *are* using a price set, one of the features of the Price Set Visibility extension is to automatically deselect another value if you select another amount. Note that this is finicky, and only works if there are two fields in the price set, the first is a multiple-choice field, and the second has a label of "Other" or "Other Amount".

---
Tags: civicontribute
---


# Question
Title: Serialization of 'Closure' is not allowed at classloader.php
After installing the latest version of CiviCRM (5.56.1) I cannot open my website anymore and log is showing this message:

Got error 'PHP message: Uncaught PHP Exception Exception: "Serialization of 'Closure' is not allowed" at /data/sites/web/instituutvlaamsevolkskunstbe/cms-install/4466-instituut-voor-vlaamse-volkskunst/production/vendor/civicrm/civicrm-core/CRM/Extension/ClassLoader.php line 85'

and drush cr returns:

Serialization of 'Closure' is not allowed

Drupal version 9.5.0 PHP version 7.4.33

I cannot find anything related

Thanks, Stefaan

# Answer
> 3 votes
Composer 2.5.1, just released, fixed this. Run `composer self-update`, then `composer install` on the site to update the class loader.

Composer 2.5 is not compatible with civi, yet. Use `composer self-update --rollback` for now; then run `composer install` again on your site.

---
Tags: drupal
---


# Question
Title: How to count individuals by age bracket?
I wonder if it is possible in search kit to create a query that counts individuals by age bracket. A count by age is very straightforward but I don't know how to define age brackets like 0-10, 10-20, etc.

Thanks!

# Answer
> 3 votes
I think the answer to this is to use Data Segmentation which is a feature added in very recent releases.

The workflow is something along the lines of

* create a bunch of Data Segments (eg one for each age group)
* add these segments as values in the Search Kit

(i will ask my colleague to explain in a bit more detail)

# Answer
> 7 votes
I was able to create the search, thanks to the input of petednz.

First, create a data segmentation for the age brackets, like so:

Next, you can use the data segment in the group by clause of the query, like so:

---
Tags: searchkit
---


# Question
Title: "Payment Method" (in Contribute) vs. "Payment Processor" (in Events)
you've been very helpful before, so I'm hoping you can help again here. I "inherited" a WordPress + CiviCRM site, and therefore I did not do the installation / configuration. We are having an issue with the site now where the credit card processor both works properly and appears in a way that we like on our Contribute page, but when the same processor is called on an Event page, it looks bad / different, and it simply doesn't work. The only difference I can see is that Administration for the Contribute page has a "Payment Methods" section in addition to the "Payment Processors" section, but the Events page ONLY has "Payment Processors."

In the Contribute page management area, I am able to select Payment METHODS, where Credit Card has been assigned to the Credit Card \> Stripe payment processor, and we get this field which works brilliantly:

However, in the Events page management area, I can only select a Payment PROCESSOR, where Credit Card is obviously assigned to Stripe (as mentioned above). That results in the display below, and trying to process any payment result in "Invalid request."

Can anyone point me in the right direction toward resolving this?

# Answer
> 1 votes
Payment Processors and Payment Methods are both settings that apply to all contributions, no matter if they are associated with an event or not. If you click on those two Payment Processors links in the menu, they both go to the same page, i.e. it's just one setting, not two different ones. Payment Methods are associated with Payment Processors and also apply to all contributions.

For both event configuration and contribution page configurations, you can only select Payment Processors. If you select the same ones, you should get the same result on the event page or contribution page.

It looks like perhaps you have Paypal and Stripe enabled on your contribution page and just Stripe enabled on your event page, which is why you are getting the Stripe Link thing.

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


# Question
Title: How can I edit the names (not just the labels) for custom field names?
I'm working with some historic data in a Civi database. For about ten years now we have created a custom field set each year to collect the same two pieces of information via an annual survey. We did it this way rather than using a field set which could store multiple values, because of perceived issues accessing data from multi-value fields (via Views etc.).

So I've now got ten custom field sets, and I'd like to move the custom fields into one larger field set. But the fields from one set have the same machine name as the fields in another set, and so Civi won't let me move them into the same custom field set.

Of course it's easy to change the field label via the UI, but there's no way to edit the machine name of the field. My assumption is that editing custom field names is problematic, otherwise there would probably be a way to do it. So before I get into the database and start editing field names there, I thought it best to ask: will editing field names in the DB break things? Is there a better way to do it, or am I stuck with what I've got?

# Answer
For custom fields it's only problematic if there is custom code that references those field names, including mgd files or install hooks, or if there's some extension that stores that name in the database somewhere else in order to reference it. You'd need to update all those too.

But yes it's just a matter of changing it in the database (`civicrm_custom_field.name`).
> 1 votes

---
Tags: custom-fields
---


title: How to sum contributions in searchkit?

text:
# Question
Title: How to sum contributions in searchkit?
Sorry for the very basic question but I'm a bit stumped!

I want to create a donors report with searchkit. Something simple : name and total donations.

I see in this answer an option to "sum" a column. But when I look on my install (Civi 5.52.2) I don't see that option. And when I look on dmaster.demo I also don't see that option (see screenshot).

Where can I find the "sum" field transform?

# Answer
> 1 votes
Start with the contributions entity under "Search For", and then group by Contact ID. Then you will see the sum option under field transformations.

---
Tags: searchkit
---


# Question
Title: fatal error "Uncaught ReflectionException" after upgrade to 5.50
WP 6.0 Civi 5.50 error is Fatal error: Uncaught ReflectionException: Class Civi\Api4\Service\Spec\Provider\SearchDisplayCreationSpecProvider does not exist in /home/lesley/public\_html/wp-content/plugins/civicrm/civicrm/CRM/Api4/Services.php line 86

# Answer
Remove all file start with `CachedCiviContainer` in `files/civicrm/templates_c`

Example: `files/civicrm/templates_c$ rm -rf Cached*`

There after civicrm will add `Civi_Api4_Service_Spec_Provider_SearchDisplayCreationSpecProvider` service to `CachedCiviContainer...` file.

Example:

> grep -inr 'SearchDisplayCreationSpecProvider' .
>
> ./CachedCiviContainer.4b01fcc15bfea5d03c88a31ab3b56016.php:1891:
> $instance-\>addSpecProvider(($this-\>services\['Civi\_Api4\_Service\_Spec\_Provider\_SearchDisplayCreationSpecProvider'\] ?? ($this-\>services\['Civi\_Api4\_Service\_Spec\_Provider\_SearchDisplayCreationSpecProvider'\] = new \Civi\Api4\Service\Spec\Provider\SearchDisplayCreationSpecProvider())));
> 0 votes

---
Tags: upgrade
---


# Question
Title: Expired token (checksum) simply redirects to main page instead of giving error
I have a profile page setup where users can view their own data and modify it if necessary.

They get emailed a link to the page with a checksum token, so they do NOT have to login.

The page works fine when the checksum is not expired.

Under Administer \> System Settings \> Misc you can adjust the lifespan of the token (default is 7 days).

Once the token expires, if the user clicks on the link, they are simply redirected to the home page of the site.

This is terrible user experience as they are not going to know why they can not access their profile anymore.

It would make a lot more sense that they stayed on the profile page they linked to, and then the profile page should generate an error saying something like "Sorry your checksum token has expired. You will need to get a new one to access this page."

This seems like basic functionality that should be included, or maybe I am just missing something?

# Answer
> 1 votes
I agree - that behaviour is not good. I think there is an extension that changes that but I can't find it just now. Maybe someone else can link to it. That said, the handling of checksums has changed recently with the 'authx' extension which may offer new options for handling expired checksums.

# Answer
> 0 votes
An extension could solve your issue : https://civicrm.org/extensions/form-access-restrictions

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


# Question
Title: Is it possible to insert the values from a submitted Form Builder form into a specific contact by modifying the form's URL?
I've built a form using Form Builder. The form asks for details needed for a police background check but it doesn't ask for the applicant's name or email because it's assumed a contact has already been created into the database for the applicant. My idea is to email a link to the form and modify the URL somehow so that when the form is submitted its contents gets attached to the right contact. The right contact would be determined using a token set in the message template. **Is this possible?**

# Answer
I hadn't spotted the "Accept ID from URL" checkbox until now. This seems to do the trick.
> 1 votes

---
Tags: formbuilder
---


# Question
Title: How can I Move My CiviCRM (Wordpress) to A Subdomain?
I originally installed CiviCRM in Wordpress on our regular website. I am now wanting to uncomplicate that website by moving our CiviCRM installation to another subdomain so it can be used separately from our main website in a second Wordpress installation. I haven't been able to find a recommended procedure for our specific use case.

Note: CiviCRM is installed in a separate database from Wordpress already. The new subdomain is currently empty.

Edit, clarification, and question based on the answer below:

We do have links to the newsletter subscription form. And we have the admin utilities plugin installed. I also have some custom roles created.

I am planning to run Wordpress in the subdomain using the same host as the current site, so the CiviCRM database itself doesn't necessarily have to move.

I was wondering if it would be possible to simply disable the civicrm plugin, copy the existing website over to the new location, duplicating the database for wordpress, but using the existing database for CiviCRM. Perform whatever find/replace was necessary to change domain.com to new.domain.com, and then re-enable CiviCRM? If that could work, I'd just need some idea of what find/replace would be necessary.

# Answer
OK. I did find William's answer helpful, but ultimately this is roughly what I did. I did it this way so I wouldn't have to spend time worrying about configuring a new Wordpress install to exactly match all the features of my current one with relation to CiviCRM:

1. I backed up everything!
2. Disabled the CiviCRM Admin Utilites and CiviCRM plugins (in that order, apparently, or I got a fatal error) Created the new subdomain and a new Wordpress (WP) database
3. Exported the WP and CiviCRM databases
4. Performed a find/replace on each extracted database, somewhat painstakingly, to switch any appropriate references from the old example.org to new.example.org
5. Imported the modified WP database to the new database I created for it
6. Imported the modified CiviCRM database to overwrite the original copy (which I had backed up just in case!) Transferred the files from the live WP site to the new domain
7. Updated the CiviCRM civicrm.settings.php file in the wp-content/uploads/civicrm folder to change hard coded references from the old example.org to new.example.org, and a few paths that were also hard coded to the file system that looked like "/home/username/www/subdomain-name/wp-content/plugins/civicrm/civicrm/)
8. I followed some of the steps in this document to delete some cached files and rebuild cache and menus. I also ended up having to go to the status page which directed me to update Stripe hooks.
9. Once I was sure things were working well I performed some cleanup on the old website to remove the CiviCRM and CiviCRM Admin Utilities plugin files.
10. I removed unnecessary WP content on the new website that had transferred over from the old website.
11. I updated the CRON job in my hosting panel to point to the new installation.
> 2 votes

# Answer
If I understand you correctly, you currently have CiviCRM installed within your main (WordPress) website. You would like to move the CiviCRM instance from your main website and to a separate WordPress instance on a subdomain.

The answer to this really depends on how complex you existing installation is and how much it integrates with your WordPress website.

I would suggest that you start by reviewing your existing installation to check for any integration between WordPress and CiviCRM.

* Do you have any public forms on your website that store data in CiviCRM? e.g. a donation form or newsletter sign up
* Do you have any pages that show data from CiviCRM? e.g. a list of current members or recent donors
* Does access to your site users depend on data from CiviCRM? e.g. are parts of the site member-only?
* Do you have any WordPress plugins that interact with CiviCRM? e.g. Member Sync, Groups Sync, Caldera Forms etc.

If you have answered 'yes' to any of the above, you will need to ensure that you recreate this functionality on the new site.

Presuming that your site is relatively simple and you don't have any of the integration listed above, it should be fairly straightforward to move your installation of CiviCRM from one WordPress site to another.

You should be able to follow the same steps as if you were switching from Drupal to WordPress. You will be switching from WordPress to WordPress but the steps are the same.

I'd suggest you also read the documentation on switching servers.

I strongly recommend that you do a test run on a staging server first to make sure that it works correctly.

EDIT

You've asked if you could simply duplicate the existing site. Yes, that should work fine. You could then disable/remove any WordPress functionality that you don't need from the new copy and remove CiviCRM from the original site.

In terms of updating the URL you can find details of the changes you need to make in the sysadmin guide. You will also need to update the URLs in the WordPress database see this support article for details.
> 1 votes

---
Tags: wordpress, migration, domain
---


# Question
Title: You do not have permission to access this content in HTML Profile Form
We have published a CiviCRM profile form at *https://www.redmaternoinfantil.org.mx/educacion/*, we place this form with the HTML code that CiviCRM provided me.

We want to receive the information external to our CiviCRM but when trying to send the form, it automatically redirects us to a permission denial link.

```
  https://www.redmaternoinfantil.org.mx/civicrm/?page=CiviCRM&q=civicrm%2Fadmin%2Fuf%2Fgroup

```

The message on the screen is

> You do not have permission to access this content

```
<div><input name="entryURL" type="hidden" value="https://www.redmaternoinfantil.org.mx/civicrm/?page=CiviCRM&amp;q=civicrm%2Fadmin%2Fsetting%2Fpreferences%2Fdate&amp;page=CiviCRM&amp;action=update&amp;id=7&amp;reset=1" />
<input name="gid" type="hidden" value="15" />
<input name="contact_sub_type_hidden" type="hidden" value="Beneficiarias" />
<input name="_qf_default" type="hidden" value="Edit:next" />
</div>

```

Log:

> \[debug\] $backTrace = #0 /bitnami/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(441): CRM\_Core\_Error::backtrace("backTrace", TRUE)

# Answer
> 1 votes
Can you make sure the anonymous and authenticated users have 'CiviCRM: profile create' permission.

# Answer
> 0 votes
In the profile settings, under the Advanced section at the bottom, what do you have for "Redirect URL"? You can put a url for a public page that says "Thanks" or something.

---
Tags: wordpress, webform-civicrm, profile, civicrm.settings.php, html
---


title: Civicrm and Opayo ( formerly sagepay )

text:
# Question
Title: Civicrm and Opayo ( formerly sagepay )
I'm trying to integrate Opayo with CiviCRM, I found an old extension but it seems to be unsupported for my CiviCRM version, is there a current extension for CiviCRM and Opayo?

# Answer
> 2 votes
Opayo is now supported via Omnipay extension

---
Tags: payment-processor
---


# Question
Title: How to enable a specific role to edit own content in CiviCRM Contact Form?
How to allow a specific Drupal role to modify its own content in the CiviCRM Contact form (civicrm-contact/%user)? I don't see any permissions like "edit own content" for type nodes in admin/people/permissions for the CiviCRM contact entity. Do you have a solution? Thanks

# Answer
> 1 votes
You can use standard Drupal access hooks and place whatever custom logic you like. https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook\_ENTITY\_TYPE\_access/9

Here is a possible way. Add this hook implementation in a custom module. You can have any custom logic there.

In this example, I look up the contact id via uf\_match record for the user, and see if the contact id being viewed matches the user's contact id. If so, it should grant access.

This is off the cuff, but should point in the right direction

You'll need the proper 'use' statements at the top of the file for EntityInterface, AccountInterface, and AccessResult.

```
function YOUR_MODULE_civicrm_contact_access(EntityInterface $entity, $operation, AccountInterface $account) {
  if ($operation == 'update' && $account->id()) {
    \Drupal::service('civicrm')->initialize();
    try {
      $uf_match_result = civicrm_api3('UfMatch', 'get', [
        'sequential' => TRUE,
        'uf_id' => $account->id(),
      ]);
      if (!empty($uf_match_result['values'][0]['contact_id'])) {
        return AccessResult::allowedIf($entity->id() == $uf_match_result['values'][0]['contact_id']);
      }
    }
    catch (Exception $e) {

    }
  }
  return AccessResult::neutral();
}

```

It would also be possible to check if the $account has a permission, like 'edit my contact' in the allowedIf() conditional

$account-\>hasPermission('edit my contact');

---
Tags: drupal, forms, civicrm-entity, roles, edit
---


# Question
Title: How can I offer event registration cancellation but not registration transfer?
I want to allow participants to cancel a registration but not to transfer it to someone else. It seems that CiviEvent offers either both or neither. Is there a way of just enabling one?

# Answer
You need the self-service cancel only extension.
> 3 votes

---
Tags: civievent
---


title: PEAR packages and PHP 7.4

text:
# Question
Title: PEAR packages and PHP 7.4
I am upgrading to CiviCRM 5.56.1 on a Drupal 9 application. I started getting errors on files missing and I realized that the following PEAR packages were missing:

* DB\_DataObject
* HTML\_QuickForm
* HTML\_QuickForm\_Controller

I installed the packages with `pear install` since these are old packages that are not on packagist.

Question 1: Is there a documentation page listing all PEAR packages required?

Right now, I get a few PHP syntax errors related to those packages, running on PHP 7.4. For example, `"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? DataObject.php:4255` and `syntax error, unexpected 'new' (T_NEW) in /usr/local/lib/php/HTML/QuickForm/Controller.php on line 213`. These make sense since, for example, `HTML_QuickForm_Controller` had its last release in 2009.

Question 2: Am I missing something here? Does CiviCRM has dependencies that do not support recent version of PHP, even though CiviCRM core states that it supports PHP 7.4?

# Answer
I was updating from an early version of CiviCRM (4.7.30) to the latest one, together with an upgrade from Drupal 8.7 to 9.4. I had to do progressive updates i.e. to 5.26.2/8.8, then 5.51.3/8.8, then 5.56.1/9.4.

I was initially missing the `civicrm/civicrm-packages` in composer - I thought if it is required it should be a dependency of `civicrm/civicrm-core`. Apparently that's not the case, so I had to add it as a dependency of the application.

I still had some issues due to `civicrm/civicrm-core` not properly declaring its dependencies in earlier versions e.g. 5.26.2, so I had to add 1 or 2 PEAR packages in the application's composer.json to go through that step and then remove it after moving to the latest version that does declare its dependencies correctly.
> 2 votes

---
Tags: quickform, php7
---


# Question
Title: Frequency distribution for radio custom fields / survey / statistics / report
we have set up a tiny survey with a bunch of custom fields with data type int and a radio controlled option set

```
Value | Label
-------------
 -1   |  No
  0   |  Unknown
  1   |  Yes

```

attached to activities of a specific type.

We're looking for a way to create a statistical evaluation called frequency distributions. The result would sum up the occurences of every option value for a set of fields and display it by label.

https://en.wikipedia.org/wiki/Frequency\_(statistics)#Frequency\_distribution\_table

I'm not a native english speaker but from my understanding of civicrm docs and code there's is no report template (neither in core nor in ExtendedReports or Report+) and no dataprocessor source/aggeragation field for this popose.

How/where would you implement it?

I thought about a dataprocessor custom group source which serves the data and a new aggregation type. But dataprocessor seems not to allow injecting new source classes from outside it's very own Factory class. And a customized fork maintained by me is'nt what want.

I know I can use drupal 7's view aggregation but I would prefer extending civicrm.

# Answer
> 1 votes
In case anybody searching for this: We've developed a tiny extension for this purpose and published under https://github.com/kompetenzz/net.kompetenzz.freco. This extension provides API4 and UI to compute frequency distribution across a set of custom fields.

---
Tags: extension, civireport, core
---


# Question
Title: The "Update" action in SearchKit is not working after upgrade to 5.57.0
I updated the 3 sites I manage yesterday to 5.57.0. One is a D7 site and two are WP. Now on all of them, if I use SearchKit and then "Action \> Update" the window to do the action does not pop-up. It is the same if I use SearchKit for contacts or contributions and again, it is happening on all 3 site. I am even seeing the same issue on the sandbox site: https://dmaster.demo.civicrm.org/

# Answer
See https://github.com/civicrm/civicrm-core/pull/25289

Will be fixed in 5.57.1, or it's a simple patch you can make.
> 0 votes

---
Tags: searchkit
---


title: How do I configure SMTP with STARTTLS?

text:
# Question
Title: How do I configure SMTP with STARTTLS?
I know that CiviCRM can send e-mail using SMTP and SSL by prefixing ssl:// to the SMTP server name, but my organization uses Office365, which only supports SMTP with TLS. Is there a way to get CiviCRM to work with the Office365 SMTP server (ideally without resorting to Postfix and sendmail)?

# Answer
> 7 votes
For performance, avoid remote SMTP entirely.

Using SMTP directly to hosted mail products will be tangibly slower while the SMTP transaction blocks the PHP request; having a "real" local MTA which then smarthosts to Office 365 allows CiviCRM to offload messages quicker (local process/filesystem versus remote network).

Stack Exchange prefers documenting the actual process to external links but in this case I'll do the latter since you have several options, and hey, I'm already not answering your actual request :)

# Answer
> 3 votes
CiviCRM supports TLS connections - and IIRC you just preface with ssl:// (even though it's TLS, not SSL) and select the appropriate port.

However, TLS is currently broken if authentication is required - see https://issues.civicrm.org/jira/browse/CRM-14814 and http://forum.civicrm.org/index.php?topic=21960.0. There seems to be an open PR (https://github.com/civicrm/civicrm-packages/pull/66) - I'm not sure why this wasn't merged, but it's against Civi 4.4, and would probably need to be ported forward.

# Answer
> 1 votes
I have used tls://pod51010.outlook.com:465 to connect to an Office365 SMTP server with other software (Forum). Since CiviCRM allows us to specify the port, I would just use tls://pod51010.outlook.com as the SMTP Server Name.

I cannot test with CiviCRM right now as I no longer have an Office 365 account, but I would give that a try first.

# Answer
> 1 votes
As Jon G notes, TLS is currently broken. The Forum reference gives patching information, which I've just now successfully applied to CiviCRM 4.6.8, running under WordPress 4.3.1. The broken module is: (your http root)/wordpress/wp-content/plugins/civicrm/civicrm/packages/Net/SMTP.php

Searching the module for the text "// CiviCRM: CRM-8744" get you to the right spot to follow the instructions given by TravelingPharaoh in the forum post, reply 10 (BTW: Thanks to TravelingPharaoh). A reboot, and you are in business.

So this is another confirmation of the need for the fix that is in progress, per CRM-14814.

Thanks, guys.

# Answer
> 1 votes
In 2023, the easiest answer is a hook in an extension, e.g.:

```
// Force STARTTLS
function wisctweaks_civicrm_alterMailer(&$mailer, $driver, $params) {
  $mailer->__set('starttls', true);
}

```

I'm not saying the other answers don't work - but this was easier than testing everything else.

Note that if you want to use STARTTLS without authentication, you need CiviCRM 5.57+ (earlier versions of the `pear/mail` and `pear/net` libraries didn't support it.

---
Tags: email, configuration
---


title: How to manage monetary display in 2023?

text:
# Question
Title: How to manage monetary display in 2023?
Based on this year 2008 thread and a few earlier threads on civi.stackexchange regarding the matter. Now (CiviCRM 5.56.2), when "Monetary Amount Display" on civicrm/admin/setting/localization?reset=1 is deprecated and gone, how do we, say, remove decimals from currency display, apart from altering `CRM_Utils_Money`?

# Answer
> 1 votes
While not a supported option, theoretically you can replace `\Civi::$statics[$cacheKey];` from https://github.com/civicrm/civicrm-core/blob/b0fff1c64cf3dd2e40b248b3b067ca30de09aeee/Civi/Core/Format.php#L220, probably in hook\_civicrm\_config in an extension, with a modified $formatter object that does what you want.

e.g. in hook\_civicrm\_config

```
$cacheKey = <figure out cachekey>
$formatter = \Civi::$statics[$cacheKey];
// make some changes to $formatter here
\Civi::$statics[$cacheKey] = $formatter;

```

But it would be nicer if there was a supported way to change the parameters that the formatter object uses.

---
Tags: currency
---


# Question
Title: Angular is being loaded twice after 5.56 update Civi menu won't load
*Have already cleared cache* several times and tried different browser.

This message appears twice in browser Console and menu won't load after update from 5.51 to 5.56 on D9. Menu was working before upgrade.

```
WARNING: Tried to load AngularJS more than once.
angular.js:15697 Error: [ng:btstrpd] http://errors.angularjs.org/1.8.2/ng/btstrpd?p0=%26lt%3Bcrm-angular-js%20modules%3D%22crmDashboard%22%26gt%3B
    at angular.js:99:1
    at c (angular.js:1944:13)
    at Object.Wc [as bootstrap] (angular.js:1984:12)
    at HTMLElement.<anonymous> (crm-angularjs-loader.js?r=HTcKBen_US:7:15)
    at Function.each (jquery.min.js:2:2903)
    at n.fn.init.each (jquery.min.js:2:846)
    at HTMLDocument.<anonymous> (crm-angularjs-loader.js?r=HTcKBen_US:6:52)
    at HTMLDocument.dispatch (jquery.min.js:3:12369)
    at r.handle (jquery.min.js:3:9088)
    at Object.trigger (jquery.min.js:3:11488)

```

This is the URL that is attempting to load:

```
https://www.site.org/libraries/civicrm/core/bower_components/angular/angular.js?r=oKGx5en_US

```

Settings

> Image Directory: \[civicrm.files\]/persist/contribute/ Image Upload URL: \[civicrm.files\]/persist/contribute/ CiviCRM Resource URL: \[cms.root\]/libraries/civicrm/core

Thanks!

# Answer
According to https://lab.civicrm.org/dev/core/-/issues/2975 there is one extra command to run after. Have created PR for documentation https://lab.civicrm.org/documentation/docs/sysadmin/-/merge\_requests/347/diffs

> composer civicrm:publish
> 2 votes

---
Tags: upgrade, menu, angular, drupal-9
---


# Question
Title: civicrm 5.54.0 status page and menus not loading after upgrade
After upgrading my CIVICRM is not working anymore. Menu's are not available and Dashlets are empty. There seems to be an AngularJS issue. The file https://www.instituutvlaamsevolkskunst.be/sites/default/files/civicrm/persist/contribute/dyn/dc.min.js.map is indeed not present. Same for this location https://www.instituutvlaamsevolkskunst.be/dc.min.js.map

\[ While copying I notice the double forward slash before sites https://www.instituutvlaamsevolkskunst.be//sites - I modified this and it does not make a difference as the files are not present anyway\]

Hope someone can point me in the right direction to fix this issue ...

Thanks

# Answer
Have are you using Drupal 8/9/10? If so try

```
composer civicrm:publish

```

from command line
> 0 votes

---
Tags: dashboard, angular
---


# Question
Title: I set up a recurring payment in real time with my credit card and then when I log in to CIviCRM it says incomplete transaction
As a donor, I go to uwoec.org and hit the donate button. I fill out all information and I click for a recurring payment and put in my credit card information and hit submit. I get a message saying I will get a receipt in my email once the transaction has been processed.
As an admin for United way of Etowah County, I login to look at my donation information and it shows my name, amount that will recur monthly and the status says Pending (incomplete transaction) with no additional information.

Please help.

# Answer
> 1 votes
Every processor is different but all must have a process that 'talks back' to CiviCRM with status update. Otherwise CiviCRM doesn't know if the payment succeeded.

The URL that you must put inside your processor normally looks like this:

> https://yoursite.org/civicrm/payment/ipn/1

Please check the configuration and instructions for your processor

---
Tags: civicontribute
---


# Question
Title: Help with mariadb crash, out of memory error
I'm trying to track down the cause of an occasional mariadb crash on my server. The system is a Linode 4GB Ubuntu 22.04 instance running Wordpress 6.1.1, apache2 2.4.52, mariadb 10.6.11, and civicrm 5.56.0.

Generally it runs fine, but once in a while it returns a 500 database connection error. Mariadb is getting killed by oom-killer at the top of the hour, when the cronjobs kick off. Restarting mariadb returns it to normal function. This is happening more frequently, maybe once or twice a week. System memory does not seem to be an issue (this is when there is not much traffic on the site):

```
 $ free -m
                total        used        free      shared  buff/cache   available
 Mem:            3923         829        2088         128        1006        2712
 Swap:            511          53         458

```

The cronjobs look like:

```
*/5  * * * *    cd /var/www/html/; /usr/local/bin/wp --user=cronuser --url=https://thehcpac.org --path=/var/www/html/ cron event run --due-now > /tmp/cron.log
*/10 * * * *    cd /var/www/html/; /usr/local/bin/wp --user=cronuser --url=https://thehcpac.org --path=/var/www/html/ --timezone=America/New_York civicrm api job.execute auth=0 > /tmp/civicrm.log

```

Which seem pretty normal.

So based on what I have read online, maybe the mariadb variables are not set correctly for this situation?

```
+-----------------+-----------+
| Variable_name   | Value     |
+-----------------+-----------+
| key_buffer_size | 134217728 |
+-----------------+-----------+
| read_buffer_size | 131072 |
+------------------+--------+
| sort_buffer_size | 2097152 |
+---------------------+----------+
| max_heap_table_size | 16777216 |
+---------------------+----------+
| tmp_table_size | 16777216 |
+----------------+----------+

```

I'm not any kind of database tuning expert, and am hoping for a pointer from someone who is. Thanks!

# Answer
The default innodb\_buffer\_pool\_size is a very low 134217728. I bumped it up by adding

```
[mysqld]
innodb_buffer_pool_size = 2G

```

to /etc/mysql/mariadb.conf.d/50-server.cnf

The problem has not recurred. So this was a generic mariadb setup issue, not really related to Civicrm.
> 1 votes

# Answer
Without addressing the MariaDB tuning directly:

Consider having the MariaDB daemon restart automatically.

I started seeing this problem after a Mosaico upgrade (2.8 maybe?). You say it's happening during times of low traffic, but my guess is that it's when a mailing goes out?

I haven't found a client who's affected enough to justify profiling this with XDebug, but you may want to try setting batch limits in the CiviMail settings to see if that alleviates your issue.
> 0 votes

---
Tags: database, mysql, cron, cron-job, mariadb
---


title: cron fails with php8

text:
# Question
Title: cron fails with php8
wp 6 civi 5.51

cron stopped working when webhost forced upgrade to php8 It's a site I've inherited - they have extension cronplus installed. I'm not sure if it's this or maybe wp-cli?

don't have cpanel access where i could generate the cron error

command is \*/5 * * * * /usr/bin/php /www/xxxxxx/public/wp-cli.phar --user=xxxxx --url=https://xxxxx.org.au --path=/www/xxxxx/public/ civicrm api job.execute auth=0 \> /dev/null 2\>&1

read somewhere that maybe password now required - but have to say a bit out of my depth here

# Answer
> 0 votes
Try running `wp-cli` as a test, just to see if it works (eg. run it without parameters). If it does not, you just found the problem, so try the latest version.

Or if you want to move away from using `wp-cli` for this, you can try some other options documented here: https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/

---
Tags: cron
---


# Question
Title: When running cv on a Joomla install, what directory should I use?
In the documentation for adding schedule jobs to crontab it says

```
cv api job.execute --user=cronuser --cwd=/var/www/example.org

```

It does not explain which directory the `--cwd` should indicate, the webserver installation root, the Joomla CiviCRM component directory (`.../administrator/components/com_civicrm`) or the CiviCRM root (`.../administrator/components/com_civicrm/civicrm`).

I've tried all three but get

```
In Factory.php line 137:

  Failed to start application

vars:show [--out OUT] [--flat [FLAT]] [--level LEVEL] [-t|--test] [-U|--user USER]

```

My problem might be something completely different of course, so I reported the problem here.

UPDATE: This was after updating to, or beyond, CiviCRM 5.56, which introduced compatibility with Joomla 4 but introduced an incompatibility with Joomla 3.

# Answer
The answer to the question is that the directory should be anywhere within the website, so given a webroot of `/var/www/html` any of these should work

```
/var/www/html/administrator/components/com_civicrm/civicrm
/var/www/html/administrator/
/var/www/html/

```

The actual problem I had was unrelated and caused by this bug.
> 1 votes

---
Tags: joomla, cv
---


# Question
Title: Cannot run scheduled jobs - cli.php errors out with uninformative "Error"
I upgraded to 5.56.0 from 5.55.2, run in Joomla 3.10, and power with php 7.4.32 and apache httpd 2.4.54. The very next cron run produced "Error". Running by hand also produces "Error".

There are no entries in access\_log or error\_log. Successive issuing of the cli command may produce warnings:

```
root@host:/var/log/httpd# php .../administrator/components/com_civicrm/civicrm/bin/cli.php -u user -p pw -e Job -a execute
Errorroot@host:/var/log/httpd# php .../administrator/components/com_civicrm/civicrm/bin/cli.php -u user -p pw -e Job -a execute
WARNING: Class Civi\Api4\Event\Subscriber\ActivityPreCreationSubscriber was expected to have a service definition, but it did not. Perhaps it needs service name.
WARNING: Class Civi\Api4\Event\Subscriber\ContactPreSaveSubscriber was expected to have a service definition, but it did not. Perhaps it needs service name.
WARNING: Class Civi\Api4\Event\Subscriber\ContributionPreSaveSubscriber was expected to have a service definition, but it did not. Perhaps it needs service name.
WARNING: Class Civi\Api4\Event\Subscriber\CustomFieldPreSaveSubscriber was expected to have a service definition, but it did not. Perhaps it needs service name.
WARNING: Class Civi\Api4\Event\Subscriber\CustomGroupPreCreationSubscriber was expected to have a service definition, but it did not. Perhaps it needs service name.
WARNING: Class Civi\Api4\Event\Subscriber\OptionValuePreCreationSubscriber was expected to have a service definition, but it did not. Perhaps it needs service name.
Errorroot@host:/var/log/httpd#  php .../administrator/components/com_civicrm/civicrm/bin/cli.php -u user -p pw -e Job -a execute
Errorroot@host:/var/log/httpd#  php .../administrator/components/com_civicrm/civicrm/bin/cli.php -u user -p pw -e Job -a execute
Errorroot@host:/var/log/httpd#

```

What should we fix to remedy this issue?

# Answer
> 2 votes
This is caused by this bug introduced in 5.56. The related pull request fixes this.

We will have to watchout when updating until the PR has been introduced.

# Answer
> 0 votes
It might be from some bad smarty code in a template. You can try installing https://civicrm.org/extensions/smarty-message-template-error-handler or applying this patch which is roughly the same thing that might make the error more visible.

Otherwise you could try running the job with `cv` and see if that gives a different error.

I assume you've checked all the civi logs too.

---
Tags: joomla, php, cron-job, civicrm-home, scheduled-job
---


# Question
Title: DB Error: unknown error when trying to send mosaico civimail
For a recently updated CiviCRM 5.56.2 + Drupal 7 (using mariadb 10.3), I got the little black box with the message "DB Error: unknown error" popping up when trying to send a mosaico civimail (e.g. as a test).

Weirdly, there was nothing helpful in the CiviCRM error log or the Drupal error log, or the sql error log or the apache error log!

I eventually discovered the error message in the browser console, which now makes some sense (since mosaico does a whole whack of js api stuff).

The error was hard to figure out because it was full of a long string it had pulled out of the civicrm\_mailing table, but if I look far enough, I can see this:

```
Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '=']","type":"DB_Error"

```

I'm not seeing this in other updated sites (or at least, not yet ...), and I had run

```
cv api System.utf8conversion

```

Anyone with a similar experience or clue?

# Answer
> 1 votes
I reran cv api System.utf8conversion and now it works.

---
Tags: database, mysql, mosaico
---


# Question
Title: Stripe Recurring Contribution generating errors when trying to add the Contribution
I've got a strange issue with a Recurring Contribution. The Recurring Contribution (Subscription) was created in November 2021, but no Contributions were recorded on the membership record.

On the Renewal date (Nov 2022) some of the events are failing with this error: https://gist.github.com/benrfairless/523235f06c1a8b1689caa2018f8ff96a.

Re-running the errored events from the "Payment Processor Webhooks" page produces the same error.

Has anyone seen this before? And do you know how to fix it?

# Answer
> 1 votes
Has the contact been merged? You can get problems recording subsequent contributions if the recurring contribution was set up on a contact that was later merged into another contact and deleted. There are updates that will hopefully be released soon to address contact merging.

One way of seeing if the contact has been merged is to look at the activities of the contact.

This doesn't fix your problem but may help to clarify the cause.

---
Tags: contributions, recurring-contributions, stripe
---


# Question
Title: CiviCRM send notification to admin if payment goes failed on recurring charges
I am using IATS payment processor. I want to get notified if any recurring charge goes failed.

# Answer
> 2 votes
welcome to CiviCRM Stack Exchange!

Navigate to Administer -\> CiviContribute -\> iATS Payments settings -\> Here you can enter an email address which should be notified of failures (first option). There are some other settings here you may want to explore as well.

# Answer
> 1 votes
As others said in the comments, CiviRules can work in this scenario; if you set it up where the trigger is "contribution changed," and the conditions are that the contribution is failed and the contribution recur ID is not null (just to eliminate the possibility of getting flagged for a failed one-time payment), you can then send an email to yourself and/or the contributor notifying you/them about the failed payment.

# Answer
> 0 votes
Believe this feature has been included in the 1.7.5 version ( https://github.com/iATSPayments/com.iatspayments.civicrm/milestone/1?closed=1 ) which is in beta stage ( January 2023 )

---
Tags: payment-processor, recurring-contributions, iatspayments
---


# Question
Title: Pulling in memberships to event participant reports
I have a requirement for a client to be able to include a participant's membership level and status into an event participant report. I've checked through the options in the report templates but none of them seem to include this. Is it something which is even possible or would it require creating something bespoke for them?

Thanks

Chris

# Answer
You should be able to do something along these lines with SearchKit. You could search Contacts with required Contact Participants and with optional Contact Memberships and then create a display with the columns you want.
> 1 votes

---
Tags: civievent, civireport
---


# Question
Title: How to un-link a CMS user from a contact (and re-link to another contact)?
If you have a contact with a linked CMS user, sometimes you want to un-link them and re-link the CMS user to another contact.

The way I've figured out to do this without having to directly change anything in the database is to create a duplicate contact for the contact you want to un-link, merge this contact with the original contact as the duplicate (moving everything to the new contact except the CMS user), then doing Synchronize Users to Contacts and finally merging the newly created contact with the contact you want the CMS user to be linked to. But that's messy. Is there a better way?

# Answer
> 4 votes
The mapping for CMS user to Civi contact is the `UFMatch` entity.

You can use APIv4 Explorer to view and change these. If you have one that is wrong, just delete the corresponding UFMatch. When the user logins in next time a new match will be created based on the CMS email address.

If you have multiple Civi contacts with the same email address you might need to create/modify a UFMatch but often just deleting the existing one is sufficient.

# Answer
> 0 votes
Merging the two civi records should give you the ability to have the CMS user transferred from A to B.

---
Tags: user-account, cms-integration
---


title: All multilingual views are now MyISAM?

text:
# Question
Title: All multilingual views are now MyISAM?
After the most recent CiviCRM security update to 5.56.2, a lot of my D7 sites (maybe all my multilingual ones?) are showing the old MyISAM Database Engine warning.

I took one example and discovered that it was all the civicrm db 'views' (not the drupal views) that were (now?) MyISAM. I'm using MariaDB 10.3

I did confirm that the default storage engine is InnoDB.

I presume it happened as part of the db upgrade part of the civi version upgrade, which was done via the command line using cv, i.e. cv upgrade:db

I believe the db upgrade will rebuild the views.

Anyone else have a similar experience and/or solution? Or is this not an issue and it's just a false reporting problem?

# Answer
Use `SELECT TABLE_NAME FROM information_schema.TABLES WHERE ENGINE = 'MyISAM' AND TABLE_SCHEMA = '<your db name>' AND TABLE_NAME LIKE 'civicrm_%' AND TABLE_NAME NOT LIKE 'civicrm_tmp_%'` \- replace "your db name" - to find which tables it thinks are wrong. That is the same query the status check uses.

Those temp tables you're seeing in the comments above are from years ago so I'm not sure why they would show up just now, but that must be it: https://github.com/civicrm/civicrm-core/pull/12311/commits/c78f866ee1bcacd88801275c9a8ada9119e2b558

To clarify the confusion inherent in the question: MyISAM views (for multilingual sites) are expected and normal!

And, for bonus points, here's some SQL to generate a DROP statement to remove the offending old tables:

```
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )  AS statement FROM information_schema.tables  WHERE ENGINE = 'MYISAM' AND table_name like 'civicrm_%';

```
> 2 votes

---
Tags: upgrade, database, mariadb
---


title: Upgrade to 5.57 failure in Joomla 3.10

text:
# Question
Title: Upgrade to 5.57 failure in Joomla 3.10
I have just upgraded CiviCRM to 5.57 in my Joomla 3.11 environment and instantly it tells me that the following error is triggered:

Fatal error: Declaration of CRM\_Custom\_Import\_Form\_Summary::preProcess() must be compatible with CRM\_Contact\_Import\_Form\_Summary::preProcess(): void in /homepages/33/d128624839/htdocs/clickandbuilds/Joomla/BackfordAreaHistory/administrator/components/com\_civicrm/civicrm/CRM/Custom/Import/Form/Summary.php on line 13

How do I resolve this?

# Answer
> 1 votes
This seems to be a duplicate of (Fixed) CRM\_Custom\_Import\_Form\_Summary error when sending one of email.

Delete this file: CRM/Custom/Import/Form/Summary.php

# Answer
> 1 votes
The issue is now resolved, but not using the response given.

Just after experiencing the error, I attempted an upgrade to Joomla 4 and that borked as well. This meant, I then had to rebuild the site from scratch. During that process, I discovered the underlying reason for both failures - my hosting provider's file number limits were being breached (Grrrh!!).

Thanks anyway for the response.

---
Tags: joomla
---


# Question
Title: Payment Shared (mjwshared) - Table 'civicrm_paymentprocessor_webhook' doesn't exist
Apologies if answered elsewhere/already (point me in the right direction please as I've not found it yet!).

I inherited a Civi+WP installation which seems to be missing this table:

```
civicrm_paymentprocessor_webhook

```
* Civi core 5.44
* Payment Shared (mjwshared) 1.0.1

During the course of updating Civi core and extensions to their latest versions I discovered this problem - which blocks updating both this extension and Stripe.

I looked at the release notes and it sounded as though it might have been introduced in 1.1 (I realised subsequently that it isn't), so I started again with a clean db and "baby steps", upgrading 1.0.1 \> 1.1 - with same results.

I then checked the production site and saw the same error in the logs there too. Aha! A pre-existing condition. Also filling the logs with huge db output, dumped each time the issue is provoked.

So... how can I get this table? When was it introduced? What is the best way forward? (as an aside: How can it *not* be present in the first place??!).

I have root access to the dev server and db, and cli tools such as cv and could write a CREATE for the table, but would like to do things the "right" way and avoid introducing any other/new problems.

Any thoughts/suggestions welcome. Thank you.

# Answer
Run below sql and check if it works

```
CREATE TABLE `civicrm_paymentprocessor_webhook` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique PaymentprocessorWebhook ID',
  `payment_processor_id` int unsigned COMMENT 'Payment Processor for this webhook',
  `event_id` varchar(255) COMMENT 'Webhook event ID',
  `trigger` varchar(255) COMMENT 'Webhook trigger event type',
  `created_date` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT 'When the webhook was first received by the IPN code',
  `processed_date` timestamp NULL DEFAULT NULL COMMENT 'Has this webhook been processed yet?',
  `status` varchar(32) NOT NULL DEFAULT "new" COMMENT 'Processing status',
  `identifier` varchar(255) COMMENT 'Optional key to group webhooks, as needed by some processors.',
  `message` varchar(1024) NOT NULL DEFAULT "" COMMENT 'Stores data sent that is needed for processing. JSON suggested.',
  `data` text COMMENT 'Stores data sent that is needed for processing. JSON suggested.',
  PRIMARY KEY (`id`),
  INDEX `index_event_id`(event_id),
  INDEX `index_created_date`(created_date),
  INDEX `index_processed_date`(processed_date),
  INDEX `index_status_processed_date`(status, processed_date),
  INDEX `index_identifier`(identifier),
  CONSTRAINT FK_civicrm_paymentprocessor_webhook_payment_processor_id FOREIGN KEY (`payment_processor_id`) REFERENCES `civicrm_payment_processor`(`id`) ON DELETE SET NULL
)
ENGINE=InnoDB;

```
> 0 votes

---
Tags: upgrade, database, payment-processor
---


# Question
Title: Cron: cli.php does not work in the latest Civicrm
This happens on Civicrm for Joomla. It prevents both upgrading to Php 8 and upgrading to latest Civicrm, as doing any of these stops the cron job.

This is what I see with Civicrm 5.49.3:

```
$ php74 domains/figg.org/public_html/administrator/components/com_civicrm/civicrm/bin/cli.php -s figg.org -u cronjob -p DeveFarl0 -e Job -a execute
PHP Deprecated:  Non-static method JApplication::getMenu() should not be called statically in /home/usiako1s/domains/figg.org/public_html/plugins/authentication/civicrm/civicrm.php on line 305

$ php81 domains/figg.org/public_html/administrator/components/com_civicrm/civicrm/bin/cli.php --help
PHP Fatal error:  Array and string offset access syntax with curly braces is no longer supported in /home/usiako1s/domains/figg.org/public_html/administrator/components/com_civicrm/civicrm/packages/DB/common.php on line 265

```

Using the latest Civicrm, the first example (with php74) generates the string "Error", and I was not able to pinpoint where it fails (I don't speak Php).

# Answer
There was a problem with `cli.php` and `cv` in 5.57.0 on Joomla. That is fixed in 5.57.1 just released.

For php versions, see the notes at https://docs.civicrm.org/installation/en/latest/general/requirements/#php You're probably better sticking with 7.4 for now.
> 1 votes

---
Tags: cron, php8
---


# Question
Title: Changing custom Contact Reference field from single to multi-select causes failure
I had a user report an issue with using a custom field. The field records who is the interviewer for a particular interview and uses a contract reference type field, and, on inspection, allows you to add multiple interviewers - the Multi-Select box was ticked. Looking at it, everything seemed fine, but I could see from the log that it was failing when you tried to add even a single interviewer. Looking at the error data (Gist of error, I could see that it was trying to add a Hex value to an integer field.

To test this, I recreated another field within in the same custom field set using Contract Reference and Multi-Select and all worked fine.

# Answer
When I checked the table details in MySQL workbench, I could see that the problem field was of type INT(10) and that the recreated field was of type VARCHAR(255) - this would make sense due to the seperator that needs to be stored. At some point in the distant past someone must have changed their minds about needing more than one person logged as an interviewer and changed the field to 'multi-select' by ticking the box.

When I tried to check it back to single and then change it back to multi-select on my local, the system froze and on checking the logs, I could see Foreign Key constraint errors.

In the end I first exported the data, deleted the the two fields, recreated them, (ensuring that the Contact Reference fields was multi select from the start) and reimported the data. All is good now.

The moral to the story is NOT to make these sorts of changes of data type. Unfortunately, the message that comes up when you do try this is '.. all data will be preserved'. This might be true, but depending on when the field was created, whether it has a search index against it etc, you might have an issue on your hands.
> 2 votes

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


# Question
Title: Delete On_Hold emails and reassign Primary Email
We are doing a bit of DB cleanup and one area we are evaluating is on-hold emails. I have run some tests on our staging site and I think we have a good path forward to remove them. However, if the email that we removed is the Primary Email, Civi does not set another email address as Primary. Is there a quick way to set a Primary email if one is not present?

# Answer
> 3 votes
Civi will set another address as Primary if you use its tools to delete but it can't do that if you rip data out from under its feet.

Deleting things directly from the database is usually a bad idea! If you delete manually you also need to manually assign another address as primary.

However, if you use the API to delete the email address another one will be assigned as the primary automatically.

If you want to delete all your on\_hold addresses (not saying that is a good idea ... but that's what you describe), then

```
$results = \Civi\Api4\Email::delete()
  ->addWhere('on_hold', 'IN', [1, 2])
  ->execute();

```

will remove them all and assign new primaries.

---
Tags: civimail, email, apiv4
---


# Question
Title: How to generate and send contribution history to each Donor
Civicrm 5.57 Wordpress 6.1.1

Hello,

Here is the scenario: We have 100 donors whose employers agreed to match their donation total for the last year. We need to generate the donation history for each of these people for the year of 2022 and send each individual their own history

Is there a way to generate these histories and email them with tokenx to the group in civimail? Or is the only way to generate each individual receipt and send it to each person on by one?

Thank you

# Answer
Transactions tokens might be useful to you?
> 1 votes

---
Tags: civireport, receipts, cdn-tax-receipts
---


# Question
Title: What CiviCRM permissions do I need to grant in order to allow "create user record" for a CiviCRM contact
What CiviCRM permissions do I need to grant in order to allow "create user record" for a CiviCRM contact?

I want to allow for a user with a certain role ("Organizer") to create a CMS(wordpress) user for a certain CiviCRM contact -- contacts the user is in a certain relation with. I would like to not only allow editing the contact for that user, but also allow for "create user record"

Is it possible to grant that permission at this granularity? Or does the "Organizer" have to get Admin privileges? Is there another way to allow the "Organizer" to effect, that the contact can get a WP account? (e.g. by providing a registration link that is tied to the contacts email adress or something of the like?)

# Answer
In wordpress it's the `create_users` permission:

And as noted in the comments by @mplh you can use a plugin like user role editor to set the permissions granted to roles.
> 2 votes

---
Tags: wordpress, contacts, permissions, user
---


# Question
Title: How to change the Wordpress role assigned through "Create User Record" function
When using the "Create User Record" function on a CiviCRM Contact record, a wordpress (or other CMS) user is created.

How can the default wordpress/CMS role of that user be modified in CiviCRM? By default it seems to be "Subscriber". Is it possible to add other roles (in CiviCRM or in the CMS)?

# Answer
It seems to be hardcoded to the default role: https://github.com/civicrm/civicrm-core/blob/79ac44cf780f867e37ed2c11cc7e9855ec6df5e0/CRM/Utils/System/WordPress.php#L873

You can configure the default role in the wordpress admin pages.
> 1 votes

---
Tags: wordpress, contacts, user, roles
---


title: Contributions Import ... Not

text:
# Question
Title: Contributions Import ... Not
Using Drupal 9.3.22 and CiviCRM 5.52.3

Importing a csv file with 44 contributions and a header row into an existing system.

The csv file is uploaded, we set the mappings, and then the next page says that there are the right number of rows, but 0 contributions, and it has no next button.

No errors are displayed, either on screen or in any of the logs.

# Answer
I "fixed" this, or at least, it now works, after trying a lot of different strategies. The last thing I did before it started working was to run

```
cv api System.utf8conversion

```
> 2 votes

---
Tags: civicontribute, import, data-import
---


title: wp-cli cron not executing

text:
# Question
Title: wp-cli cron not executing
wp 6 civi 5.52

cron command is

errors seem to be only warnings but civi reports cron not running:

```
PHP Warning:  Use of undefined constant STDOUT - assumed 'STDOUT' (this will throw an Error in a future version of PHP) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 1194
PHP Warning:  Use of undefined constant STDERR - assumed 'STDERR' (this will throw an Error in a future version of PHP) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Regular.php on line 43
PHP Warning:  fwrite() expects parameter 1 to be resource, string given in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Base.php on line 66
PHP Warning:  Use of undefined constant STDERR - assumed 'STDERR' (this will throw an Error in a future version of PHP) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Regular.php on line 52
PHP Warning:  fwrite() expects parameter 1 to be resource, string given in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Base.php on line 66
Content-type: text/html; charset=UTF-8

```

# Answer
With assistance from webhost This command worked
> 0 votes

---
Tags: cron
---


# Question
Title: How to Override System Workflow message template variables, single and batch
My client has advanced invoice requirements. In the past we had a custom Drupal module and a custom template file. Added a link "Print Invoice" to the individual contributions Form.tpl and then did a custom template file in Drupal using CiviCRM API to get the relevant data. For Batch, we added a new custom task and called our custom function in a loop.

But now, of course, CiviCRM has invoicing capability baked in, which is awesome! We edited the System Workflow Message but we had a lot of trouble using crmapi calls, and using Smarty. We also see that {php} is deprecated in Smarty 3.

So then I had the thought to just override the callback for civicrm/contribute/invoice. I did that by implementing hook\_civicrm\_xmlMenu() and providing a custom Menu.xml that uses my own class. My class just extends CRM\_Contribute\_Form\_Task\_Invoice and then I just pull in the full objects whose data I need in my own printPDF(). (Specifically, if it's an event, I want to show event start dates, etc - and if it's a membership I want to show them their membership expiration date, etc).

The problem is that the batch invoice processor seems to be hardcoded to use CRM\_Contribute\_Form\_Task\_Invoice, and I can't find a way to override it. I've tried the same approach (overriding civicrm/contribute/search in Menu.xml) but that barfs in so many places. I've looked at hook\_preProcess and changing the \_attributes, etc. I've tried adding my own custom task to the dropdown on the contribute search page, but then it barks about a missing Invoice.tpl for my custom implementation.

Long story short, I'm just not 100% sure on the best way to proceed, and of course I'd rather not just hack the core code, but would rather extend it somehow. We've had a past history of nervousness to upgrade CiviCRM, and I want to not feel like we're in that same boat after this upgrade (to Drupal 7 / CiviCRM 4.7). :)

# Answer
> 1 votes
The way I ended up having to do this was simple, but a less-than-ideal UX. My UF is Drupal.

I used Views to build a view of contributions, to somewhat mimic the native contribution search. (Specifically I added in status of pending, and is pay later), to find contributions for which invoices likely needed to be generated. I grabbed a few less columns.

I then added in civicrm\_entity to the mix, so that I could use Views Bulk Operations in Drupal. The action I chose was "pass the id's as arguments to a page," and then I wrote a custom menu callback for that page that grabs the ids and passes them into my overridden printPDF() call. That call natively supports being passed multiple ID's, so it "just worked" to print multiple invoices into a single PDF.

The downside is that my client needs to go to a special menu item I built for him when he wants to do batch invoicing, but that's livable in our particular use case.

# Answer
> 1 votes
The short answer is that you can't change that from an extension, but you can change it by patching core. Unfortunately, this requires a change in coding-convention which isn't a trivial one-line patch -- it requires understanding some other layers/concepts and changing multiple files.

The root issue here is that the coding convention has relied too heavily on static functions. For example, if you grep the codebase for `CRM_Contribute_Form_Task_Invoice`, you'll find snippets like this one (from `CRM/Contribute/Form/Task/Invoice.php`):

```
CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs, $params, $contactId, CRM_Core_DAO::$_nullObject);

```

If you could change that line to point to your own version of `printPDF()`, you'd be ready to go. But it's hard-coded -- there's no way for an extension to change it. The good news: there are better patterns which are more flexible, e.g.

```
// Example: Use a service container
Civi::service('invoice_printer')->print($contributionIDs, $params, $contactId, CRM_Core_DAO::$_nullObject);

// Example: Use a hook
CRM_Utils_Hook::printInvoicePdf($contributionIDs, $params, $contactId, CRM_Core_DAO::$_nullObject);

```

Either of those formulations would make it possible for extensions to change the implementation of `printPDF()`. The bad news: either way, you'd to have to refactor the existing implementation to match a different coding convention.

A few links that might be interesting on the general topic of statics, services, and dependency-injection:

# Answer
> 1 votes
I was lead-astray by this post, combined with my own dumb thinking. I'm not sure why the hook I finally found would not work for OP's problem, but have not looked at the bulk action. I kind of suspect the existing hook would have worked as well.

I wanted to override the invoice template and I traced `civicrm/contribute/invoice` to `printPDF()`.

"I want to override the template to download an invoice. Hmmm... I don't see any hooks to override printPDF... Ah, Tim says I should create a new hook in Core, Okay!"

Got through creating a new hook for `printPdfTemplateParams` to be raised each time before `printPDF()` calls `CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);`. Then when I went to get more details on what I need to alter in the params and finally realized that `CRM_Core_BAO_MessageTemplate` raises `hook_civicrm_alterMailParams` before loading the template. Even if you are just downloading a PDF, not sending an email. Doh!

If anyone wants the code for the new hook, I'm not submitting a PR at this time. https://github.com/ginkgomzd/civicrm-core/tree/hook-print-pdf-params

Created a PR to update the dev docs for `hook_civicrm_alterMailParams`: https://lab.civicrm.org/documentation/docs/dev/-/merge\_requests/1054

---
Tags: developer, invoice
---


# Question
Title: is there a way to use completion of an activity to trigger a contact's status change
Contacts who apply to become volunteers can select 'Befriending Volunteer' (a subset of volunteers) as a preference.

Once they pass all checks to become volunteers, their Volunteer status changes to 'approved' and the volunteer coordinator marks their Befriender status as 'pending'

The befriending team then adds a Befriender Training activity to their record; if they attend/pass, their Befriender status is updated to 'approved'.

I am wondering if there would be a (simple) way to make the status update automatic, so that once I mark the attendees as 'complete', their contact's status is automatically updated to 'approved'...

# Answer
You should be able to do this with CiviRules using the "Compare Old Activity Status to New Activity Status" trigger and then setting the status of the custom field as the linked action.
> 2 votes

---
Tags: civimember
---


# Question
Title: Unable to get Contact Form 7 working with form processor
So far...

* I've created a simple form processor and tested that it works just fine for creating new contacts.
* I've entered "/wp-json/civicrm/v3/rest" for the CiviCRM Path in the CiviCRM Contact Form 7 Settings. (Thanks for Demerit's suggestion below.)
* I've checked "Enable CiviCRM processing" in the Contact Form 7 form, and set entity to FormProcessor and action to the name of my form processor.
* I've also gone back to the CiviCRM Contact Form 7 Settings and entered the URL for my website, entered the API key for my contact (which has admin rights) and site key too, even though WordPress and CiviCRM are running on the same site. This hasn't made any difference, however.

**Am I overlooking any steps needs to get Contact Form 7 working with a form processor?**

# Answer
I eventually worked out to make this work, thanks to crucial advice from Demerit and Lars.

*A set* of CiviCRMs CF7 settings which worked for me is shown in the first diagram below. It may be that this also works by just filling in the CiviCRM Path if you're running WP and CiviCRM on the same site, however I've not tested that.

The CiviCRM tab of the CF7 form is shown in the second diagram below. You could put other stuff on the additional parameters line but nothing appears to be mandatory.

The CF7 form likes like the following:

And the form processor looks like the following:

Finally, I'd like to reiterate how helpful Lar's suggestion above was in tracking down the stupid mismatch between input field names I inadvertently introduced. Unfortunately, the form is silent in such cases and no contact is created.

Postscript. To expand on Lar's suggestion:

1. Go to https://pipedream.com/ and sign up for free account.
2. Create a new workflow and select HTTP Webhook as trigger with HTTP Requests. You will get a temporary URL that listens out for traffic. This is shown in diagram posted below.
3. Now copy this URL into CF7 CiviCRM Settings replacing the URL of your own WP site.

Pipdream will show you exactly what the CF7 is transmitting, and help you track down mismatches between the form and form processor.
> 1 votes

# Answer
extern is pretty much deprecated but also wordpress has its own REST: https://docs.civicrm.org/dev/en/latest/api/v3/wp-rest/
> 1 votes

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


# Question
Title: How to find the number of participants of a past event?
How to find the number of participants happened in the past?

# Answer
> 2 votes
I usually just go to

Events \>\> Find Participants

Then I do a search for the event and it will give you the list and a count.

---
Tags: api
---


# Question
Title: How can I restore the data from a deleted Group
Scenario is - contacts had been added to a Group (in this case for subsequent deletion) but a user then incorrectly deleted the Group, rather than the contacts in the Group.

# Answer
> 1 votes
Achieved this via SQL

Step 1. Identify contacts who the log\_civicrm\_group\_contact table shows were added to the group (and who are not now in Trash, since we can add Trashed contacts to a Group) with a query that includes the value of the new group they will be added to (in this case 893) and filters for the Group that was deleted (764)

> select 893, contact\_id, log\_civicrm\_group\_contact.status FROM log\_civicrm\_group\_contact LEFT JOIN civicrm\_contact cc ON cc.id = log\_civicrm\_group\_contact.contact\_id WHERE group\_id = 764 AND status = "Added" AND log\_action = "Insert" AND cc.is\_deleted = 0 ORDER BY contact\_id;

Then we grab the result as an SQL insert as follows

> INSERT INTO `civicrm_group_contact` (`group_id`, `contact_id`, `status`) VALUES

with rows like

> (893, 76639, 'Added')

Note we ORDERED by contact\_id as we had too bit a sql insert so it got cut off, and by ordering by id we could rerun the insert scrip for those which got dropped from previous run.

---
Tags: groups
---