# Question
Title: Upgrade error = API error: Value already exists in the database on ReportTemplate.create
I've had the above error on a couple of upgrades recently - one was an upgrade to 5.57.3 on a test system and another when upgrading the 'Report Plus' extension (see below). In both cases the upgrade stopped but appeared to be successful. I looked at the code (attached) but couldn't figure out what the problem is. Both were Drupal 7 systems. Can anyone help (please) ?

# Answer
> 2 votes
If you are on a recent version of CiviCRM you can run the Managed.reconcile api through the api explorer - in this instance I'm running it to reconcile extended reports - you can do all extensions at once, or one or two at a time. You are looking to see which extension hits an error while reconciling - the extension with the issue might not be the one that you are experiencing the error on.

Generally all declared managed entities should have an entry in the `civicrm_managed` table - eg for this entity https://github.com/eileenmcnaughton/nz.co.fuzion.extendedreport/blob/21b4be5d01384caf73ffe9c9e92f187d8f6cf84d/CRM/Extendedreport/Form/Report/RelationshipExtended.mgd.php I can find a row in civicrm\_managed and the entity\_id matches the id of the OptionValue in civicrm\_option\_value (note that `ReportTemplate` is a v3 api alias for `OptionValue` \- & Extended report uses both at the moment as it is migrating to v4

# Answer
> 0 votes
Thanks to Eileen, who said 'Generally you see that when there is an entry in civicrm\_option\_value but not in civicrm\_managed for a report being registered by the extension & the site will keep getting the error until it is fixed'. The culprit seemed to be an entry from the ReportPlus extension in civicrm\_option\_value that remained after I uninstalled this extension. This record had the label 'Activity Detail Plus'

# Answer
> 0 votes
I just ran into a similar error, is this related or a separate issue? In this case, the upgrade did not complete.

# Answer
> 0 votes
Thank you for this. Fixed by disabling the Reports Plus extension (v 2.6.2) which we were attempting to use the same time as Extended Reports (v. 5.21) on CiviCRM 5.58.1

# Answer
> 0 votes
I found my culprit with this method. What I also figured out is that when I disabled Mosaico there were many references left in the database and I got the "missing" error message. Ultimately I deleted every reference in my civicrm database and then the errors went away and now my site is clean. It seems that uninstalling and then deleting a specific extension does not remove all references ? That said, thank you for the api4 method to uncover a culprit Eileen.

---
Tags: drupal, upgrade
---


title: CRON not working on Civi wordpress

text:
# Question
Title: CRON not working on Civi wordpress
I use WordPress and CiviCRM. Although the CRON jobs work when I manually run them, they aren't running automatically. As I am new to the system, I need some help to set this up, and I don't know where else to go.

At the moment, I have to run them manually, and this isn't practical at all.

I don't know how to set them up automatically and I use instahost which uses stackcp as a hosting provider.

I don't get any error from Wordpress running automated tasks, just civi

# Answer
**FIRST**: Make sure you have the most updated version of WordPress, its entire suite of plugins and ditto for CiviCRM. Second, and perhaps before you execute the aforementioned, make sure you have a backup or your host does daily as it sounds like you are not running bare blades.

If you have cPanel, simply set the cron up as follows:

wget -O - -q -t 1 'https://www.NAME OF WEBSITE/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=USERNAME&pass=PASSWORD&key=SITEKEY''

I want to belabor a couple of things, my site is set up WITHOUT a WP directory, so thus, direct. Second, at the end there are TWO ' meaning '' not ". I have mine run every 15 minutes, but you can set the time to whatever I suppose. Next, set up a user in the User section of WordPress as SUBSCRIBER. That way if it gets *hijacked* --- the UN/PW --- it is only a subscriber. Spin up the user in CiviCRM and voila! Remember, the username may be an email or a user name depending upon how you create it in **WORDPRESS**. Cook up a HUGE password. Usually, WordPress will recommend and if you run Chrome it will as well. I generally make a note of it and save it accordingly. Finally, if you are using MFA --- sends you a text or code or whatever --- a few other steps.

Finally, protect everything with WordFence. It is free (do not pay for the paid version) and the best darn (would use a different word but don't want to get banned) security plugin I have found based on almost two decades. Clear cache if running a CDN, etc.

I'm not in here a lot, but if you are within the US (because calls are free on Google Voice) I'll walk you through it. Took me 4 years to figure it out and is one of the **BIGGEST DRAWBACKS OF CIVICRM** I have found as the novice is left without clear and concise spelling out. I'll probably write an article about it next week on my site because it was literally like the Red Sea parting for me!

Edit - you can add dev/null if you don't want the emails sent to you. If you want help let me know. And to check to make sure you have the path correct copy the https through the last character of the site key and simply toss it up in your browser and hit enter. If it only returns white, confirm that your Scheduled Jobs ticked off and grab a beer - or coffee depending upon persuasion!
> 2 votes

# Answer
If you are using crontab, check that the CRON jobs are running as the correct user.
> 1 votes

---
Tags: wordpress, cron
---


title: Safe to empty log_civicrm_group? 4.7

text:
# Question
Title: Safe to empty log_civicrm_group? 4.7
Dealing with an old 4.7 site on Drupal 7, has a huge (21 million row) log\_civicrm\_group table which I can see has been flagged as a bug in later versions - am I safe to empty/truncate that table?

Thanks!

# Answer
> 1 votes
Yes it's just for logging - you can truncate. If you think you might need the logs later you can back up just that table first and store it somewhere.

---
Tags: logs
---


# Question
Title: Finished execution of CiviCRM Update Check with result: Failure, Error message: DB Error: no such table
The error in the title appears in the Civicrm System Status after upgrade to 5.57.1

As far as I can get, it does not manage to check for the existence of new civicrm versions, so it should not be anything too serious...

This is the detail from the log entry:

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

Full message:
Finished execution of CiviCRM Update Check with result: Failure, Error message: DB Error: no such table

```

Looking under Administer \> Administration Console \> View Log I can understand what is the missing table. I see two entries:

```
[debug] $backTrace = #0 /home/usiako1s/domains/figg.org/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(954): CRM_Core_Error::backtrace("backTrace", TRUE)

```

and

```
[error] $Fatal Error Details = Array

```

Here is the detail from the first one:

```
 [debug] $backTrace = #0 /home/usiako1s/domains/figg.org/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(954): CRM_Core_Error::backtrace("backTrace", TRUE)
#1  administrator/components/com_civicrm/civicrm/packages/PEAR.php(921): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2  administrator/components/com_civicrm/civicrm/packages/DB.php(997): PEAR_Error->__construct("DB Error: no such table", -18, 16, (Array:2), "SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`\n                FROM ...")
#3  administrator/components/com_civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-18, 16, (Array:2), "SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`\n                FROM ...")
#4  administrator/components/com_civicrm/civicrm/packages/PEAR.php(223): PEAR::_raiseError(Object(DB_mysqli), NULL, -18, 16, (Array:2), "SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`\n                FROM ...", "DB_Error", TRUE)
#5  administrator/components/com_civicrm/civicrm/packages/DB/common.php(1925): PEAR->__call("raiseError", (Array:7))
#6  administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(936): DB_common->raiseError(-18, NULL, NULL, "SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`\n                FROM ...", "1146 ** Table 'usiako1s_figg.civicrm_grant' doesn't exist")
#7  administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(406): DB_mysqli->mysqliRaiseError()
#8  administrator/components/com_civicrm/civicrm/packages/DB/common.php(1231): DB_mysqli->simpleQuery("SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`\n                FROM ...")
#9  administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common->query("SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`\n                FROM ...")
#10 administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1803): DB_DataObject->_query("SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`\n                FROM ...")
#11 administrator/components/com_civicrm/civicrm/CRM/Utils/VersionCheck.php(218): DB_DataObject->count()
#12 administrator/components/com_civicrm/civicrm/CRM/Utils/VersionCheck.php(153): CRM_Utils_VersionCheck->getEntityStats()
#13 administrator/components/com_civicrm/civicrm/CRM/Utils/VersionCheck.php(125): CRM_Utils_VersionCheck->getSiteStats()
#14 administrator/components/com_civicrm/civicrm/api/v3/Job.php(751): CRM_Utils_VersionCheck->fetch()
#15 administrator/components/com_civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_job_version_check((Array:1))
#16 administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(158): Civi\API\Provider\MagicFunctionProvider->invoke((Array:8))
#17 administrator/components/com_civicrm/civicrm/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest((Array:8))
#18 administrator/components/com_civicrm/civicrm/api/api.php(22): Civi\API\Kernel->runSafe("Job", "version_check", (Array:1))
#19 administrator/components/com_civicrm/civicrm/CRM/Core/JobManager.php(131): civicrm_api("Job", "version_check", (Array:1))
#20 administrator/components/com_civicrm/civicrm/CRM/Core/JobManager.php(63): CRM_Core_JobManager->executeJob(Object(CRM_Core_ScheduledJob))
#21 administrator/components/com_civicrm/civicrm/bin/cron.php(26): CRM_Core_JobManager->execute()
#22 {main}

```

and here is the detail from the second one:

```
 [error] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => exceptionHandler
        )

    [code] => -18
    [message] => DB Error: no such table
    [mode] => 16
    [debug_info] => SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`
                FROM `civicrm_grant`   [nativecode=1146 ** Table 'usiako1s_figg.civicrm_grant' doesn't exist]
    [type] => DB_Error
    [user_info] => SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`
                FROM `civicrm_grant`   [nativecode=1146 ** Table 'usiako1s_figg.civicrm_grant' doesn't exist]
    [to_string] => [db_error: message="DB Error: no such table" code=-18 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="SELECT count(`civicrm_grant`.`id`) as `DATAOBJECT_NUM`
                FROM `civicrm_grant`   [nativecode=1146 ** Table 'usiako1s_figg.civicrm_grant' doesn't exist]"]
)

```

# Answer
Are you actually using civigrant? I guess not if you don't even have that table. So try disabling the civigrant extension then re-enabling. If that doesn't help then uninstall the extension and re-install it.
> 2 votes

---
Tags: upgrade
---


title: Migrate All Data of CiviCRM

text:
# Question
Title: Migrate All Data of CiviCRM
Old website is WordPress + CiviCRM. We are rebuilding the website, still in WordPress. I already installed CiviCRM in new WordPress website.

How to export all CiviCRM data from old website and import it to the new website.

# Answer
> 6 votes
This page might help: https://docs.civicrm.org/sysadmin/en/latest/misc/switch-servers/

I am assuming you are migrating to a new version of CiviCRM. What I would do:

1. upgrade CiviCRM on the old site to the version of the new site
2. dump the CiviCRM DB
3. restore the DB on the new CiviCRM site
4. Follow the steps in the guide in the link above

---
Tags: wordpress, migration
---


title: User Registration Profile on Wordpress?

text:
# Question
Title: User Registration Profile on Wordpress?
We're currently running a CiviCRM site based on Drupal 7, so as EoL approaches once again we're looking at migrating to Wordpress.

On Drupal we have additional questions added to the user registration form using the CiviCRM User Registration profile option. I'm trying to do the same on Wordpress and it's just not working. I've tried with an imported version of our existing CiviCRM database, and I've tried on a completely fresh install. The fields in the profile with the User Registration option on just don't show up. In fact, Wordpress doesn't show anything other than its standard registration form.

When I try to create a new CiviCRM profile, I notice the the User Registration and User Account options look like the might be crossed out?

Does WordPress just not support this function at all, or is there some other option or further plugin I need to accomplish it?

# Answer
> 1 votes
Unless I am misunderstanding your question. Create the profile like normal, but go to advanced settings and require account creation. We have this setup for our memberships.

---
Tags: wordpress, profile
---


# Question
Title: How Do you Display a Street Address using Searchkit?
I am performing a search in searchkit and I want to display the primary address in the search results. I can easily add city state and zip, but I cant seem to add the street address fields. Instead a number is appearing. I am assuming I need to transform the number somehow, but unsure what to do. Typically in reports I would add street address and supplemental addresses, but that is not an option in searchkit.

# Answer
In dmaster I just checked in SearchKit and can see a field for Address (Primary) Street Address.

Here currently but will flush in a few hours: https://dmaster.demo.civicrm.org/civicrm/admin/search#/edit/13
> 1 votes

---
Tags: search, search-results, searchkit
---


# Question
Title: How to add a Custom field that requires a certain value in civicrm contribution page?
in my Contribution Page I'd like to ask the donor to accept some privacy rules. For that I'd like to add a custom field into a Profile, add that to the Contribution Page (that works) and only accept the form if the yes/no custom field is answered with a `yes` (radio button).

Is that possible? Is there some other possibility to implement my use case in a Contribution Page?

# Answer
A possible solution is to not use a `yes/no`-type of Custom Field, but an alpha-numeric one, choose `check-box` with only one answer as Field Input Type and set the Custom Field as `required` in the Profile that is added to the Contribution Page.
> 2 votes

---
Tags: custom-fields, profile, contribution-page
---


# Question
Title: Can you change your default 'Activity Status' for adding a new activity?
Can you change your default 'Activity Status' for adding a new activity? We use completed far more than scheduled...

# Answer
> 4 votes
Yes, if you have access to your database, otherwise I don't think so.

You can edit your database. Look for the table called civicrm\_option\_value and search for WHERE `label` LIKE 'Scheduled' and WHERE `label` LIKE 'Completed' and change the values of is\_default to 1 or NULL

Here are the exact commands you can run:

```
UPDATE civicrm_option_value cov JOIN civicrm_option_group cog ON cov.option_group_id = cog.id SET cov.is_default = NULL WHERE cov.name = 'Scheduled' AND cog.name = 'activity_status';
UPDATE civicrm_option_value cov JOIN civicrm_option_group cog ON cov.option_group_id = cog.id SET cov.is_default = 1 WHERE cov.name = 'Completed' AND cog.name = 'activity_status';

```

# Answer
> 2 votes
Yes, sorta! If you don't want to operate on your database directly you can configure some rules to make it work. Instead of actually changing what the default status is, you create a rule to set the status according to your wishes.

Use the CiviRules extension: https://civicrm.org/extensions/civirules.

Create a new rule and for the *Trigger* select "Activity is added". Add any *Conditions* you want. And give this rule the *Action* "Update activity status" which can then be whatever you want.

With that rule in place any time you create an activity its status will get overridden to be whatever you configured it to be.

If you don't want the default status to be overridden all the time but only some of the time, then you can add conditions to that rule to specify when the status should be set. If you wanted you could make various rules to automatically set the status differently in various situations.

# Answer
> 2 votes
Here's another way to do it using api explorer. Just replace "yoursite" with your site, and this link will take you to the explorer with the necessary fields all filled in. Just click execute. It's smart enough it will at the same time remove default from the old status.

`https://yoursite/civicrm/api4#/explorer/OptionValue/update?where=%5B%5B%22name%22,%22%3D%22,%22Completed%22%5D,%5B%22option_group_id:name%22,%22%3D%22,%22activity_status%22%5D%5D&values=%5B%5B%22is_default%22,%22true%22%5D%5D`

# Answer
> 1 votes
I wrote a small extension that makes it possible to change the default activity status in the database, without having to do a change directly in MySQL. Admittedly, it's not really simpler than doing it directly in SQL, but I plan on making it available directly from the CiviCRM "Manage Extensions" screen.

It can be downloaded from CiviCRM's extension directory: activitystatus.

# Answer
> 0 votes
I modified in my custom templates library CRM/Activity/Form/Activity.tpl, adding a small jQuery script at the bottom of the file.

It looks like so:

```
{literal}
<script>
CRM.$(function($) {
     $('select#activity_type_id').change(function() {
         $('tr.crm-activity-form-block-status_id').hide();   // hide status ID
         $('#status_id').val('2');   // value from status ID selector
     }
}
</script>
{/literal}

```

It hides the selector after changing Activity Type, and sets the status value to 'Completed'.

Hope, helps.

---
Tags: activities, default-settings
---


# Question
Title: Enable CiviCase component programatically
I am working with CiviCRM 5.59.3, and a drupal module that integrates with CiviCase. How can I check if the CiviCRM component is enabled and enable it if it is disabled? I need to do this with php.

# Answer
> 3 votes
Calling `CRM_Core_BAO_ConfigSetting::enableComponent("CiviCase");` will enable it if not enabled already.

---
Tags: drupal, civicase, drupal-9
---


title: WordPress Cronjob Oddities

text:
# Question
Title: WordPress Cronjob Oddities
WordPress v6.1.1 CiviCRM v5.59.2

So, my cronjob appears to work; however, there are some oddities in how it works and there are errors picked up in the email that is delivered.

The oddities are as follows and change up about every 12 hours with no rhyme or reason:

1. Processed as Activity: Drivers Can Be Contractors: Calif. Panel Mostly Backs Prop 22
2. Processed as Activity: No Retrial For Weinstein On LA Sex Assault Counts
3. Processed as Activity: Security alert for coo@foreclosurepedia.org

Now, I am in shared hosting on Business Cloud wherein, I have several websites. With respect to #3, it is citing my foreclosurepedia.org website (and email address).

I also have two errors for jobs. One is for scheduled emails and the other is for SMS, that we have never used.

1. Finished execution of Send Scheduled Mailings with result: Failure, Error message: API permission check failed for Group/get call; insufficient permission: require access CiviCRM
2. Finished execution of Send Scheduled SMS with result: Failure, Error message: API permission check failed for Group/get call; insufficient permission: require access CiviCRM

Below is the cronjob set up for cPanel. The user is an Editor not an Admin in the WordPress hierarchical roles using the WordPress ACL. (I can change it to Administrator, but seems *scary* as having multiple administrators isn't the best way.) It is set up to run every hour. It updates all of the Scheduled Jobs other than the two errors and those just happened 19MAR23.

Cron xxx@xx wget -O - -q -t 1 'https://www.iafst.org/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=username&pass=password&key=key' --- it has a second ' at the end as it is required for cPanel.

Also, would the errors about the API permission check occur because we are on MariaDB v10.6.11, which is similar to MySQL 8.0. I found an article that stated MySQL v8 triggers connection errors due to how MySQL 8 defaults to auth\_socket connections. I am guessing that by executing ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql\_native\_password BY 'password'; fix this?

Added on 19MAR23 at 1439EDT: So, the Cronjob appears to be happy as it says: Cron Running OK Last cron run at March 19th, 2023 2:00 PM. The errors are gone. All I did was utilize the WordPress ACL and create the CiviCRM Admin Role and assign it to the cronuser. Does this mean I no longer have to mess with the MySQL change cited in the article below (which is MariaDB on my side)? Thanx!

Article located here IN RE: Last paragraph.

# Answer
> 1 votes
The errors have stopped and the cronjob now functions properly. The only thing I did different was create the CiviCRM Admin Role and apply it through the WordPress ACL feature. It solved the error for API issues and appears to have cleared up the errors via email. I cannot comment on whether the cronuser account could be set at a lower level than CiviCRM Admin Role as it is beyond my knowledge. I can say that the cronuser inside of WordPress is set to Subscriber. Honestly, since so many folks have problems with this (I put it off for nearly 5 years now) I would have thought someone would have spelled out IN CLEAR AND PRECISE TERMS, what roles were necessary to assign to kick off the Scheduled Jobs. If anyone might know the answer I would BE GREATLY APPRECIATIVE!

Here is the document discussing it all:

https://docs.civicrm.org/user/en/latest/initial-set-up/permissions-and-access-control/

# Answer
> 2 votes
The permissions that your scheduled job runner needs depends on what permissions are needed for the jobs you have selected to be run. If Job A requires permissions 1 and 2, and Job B requires permission 3 and you do a typical `cv api Job.execute` to run them, then your user needs permissions 1,2 & 3 etc.

However, most jobs don't clearly identify what permissions they need making it hard to know what to specify. On top of that, the documentation writers obviously don't know what combination of jobs you are going to enable - so the documentation is not going to tell you a minimum set of permissions.

Generally the cron user is set up as admin so it has full access to everything it might need. The list of what jobs are run is managed by admins.

If you have separate cron entries for specific jobs (eg `cv api Job.mail_report`) you could try to identify the minimum set of permissions needed and configure a cron user with that - but if you also have a generic admin user for other jobs, it is not clear what the benefit is.

I do agree the documentation at https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#choosing-a-cms-user could be more helpful. It says the user needs 'correct permissions' but does not suggest how you might figure that out. Maybe when you have got things working you could improve that section?

---
Tags: wordpress, cron-job
---


title: how do I count results in API v4

text:
# Question
Title: how do I count results in API v4
experimenting with refactoring some old code and figured I would experiment with apiv4. the first hurdle was figuring out how to use the ArrayObject that is returned.

in apiv3, for example I would look at the count value in the array. in apiv4 there is no such value.

my api v3 call looks like this

```
  $result = civicrm_api3('Contact', 'get', array(
  'return' => array("custom_90", "custom_91", "custom_85", "custom_88", "custom_143"),
    'id' => $alum_cid,
    'custom_143' => $sal['id'],
     ));
  if ($result['count'] != 0) {
    do things
  }

```

my apiv4 call looks like this

```
$results = \Civi\Api4\Contact::get()
  ->setSelect([
    'Employment_History.Salary_Yearly_',
    'Employment_History.Currency',
    'Employment_History.Employer',
    'Employment_History.End_Date',
    'Employment_History.relationshipID'
  ])
  ->addWhere('id', '=', $alum_cid)
  ->addWhere('Employment_History.relationshipID', '=', $sal['id'])
  ->setLimit(25)
  ->execute();

```

how do I get the count of the results?

# Answer
the way the api works now, the thing returned is an ArrayObject which you can call functions on, one of those is count()

so just count the results; and then loop over them as you would if it was a normal array

```
  if (count($results) != 0) {
    foreach ($results as $result) {
      do things
    }

  }

```
> 1 votes

# Answer
See https://docs.civicrm.org/dev/en/latest/api/v4/usage/ where it says:

* $result-\>count(): get the number of fetched (if LIMIT used) or matching results (if row\_count included in select).
* From CiviCRM 5.50+ $result-\>countFetched(): get the number of fetched results. If you used LIMIT this won't exceed that number (but could be less).
* From CiviCRM 5.50+ $result-\>countMatched(): get the total number of matching results. If you only fetched a subset (with LIMIT) you are required to add row\_count to the select clause.
> 2 votes

---
Tags: api
---


title: Add relationship to event participants

text:
# Question
Title: Add relationship to event participants
Is there a quick and simple way of adding a relationship to the participants of a particular event all at once? When we have people register for any event, we would like to add a specific relationship to another contact of a different contact type to each of those contacts at once. Naturally, we can do this one by one by going into the contacts details but this is slow. I tried using Find Participants, listing the participants for a specific event and then clicking the Action button in the hope that one of the options would be 'Add relationship' but it wasn't there. Any ideas?

# Answer
> 3 votes
Welcome to SE!

Using "Find Participants" gives you the Participant records (the record of a contact's participation in an event), but to create Relationships you want the Contact records.

Go to `Search > Advanced Search`, open up the `Events` section and add whatever parameters you want there, and then `Search`. After you have selected some/all of the results, the `Actions` dropdown show `Add relationship` actions

---
Tags: civievent, relationships
---


# Question
Title: Event Calendar extension current-week view
I want to show one week of events using the Event Calendar extension without having a timescale for the day as the default "Week" view provides. As shown highlighted but always for the current week.

Is this possible? TIA

# Answer
If you refer to the CiviCalendar extension (backend), you find the respective setting under **Administration / Calendar Settings \> Default tab for calendar**.

If your question is about the Event Calendar Extension (frontend), you could untick the option "Show Events by Month?" and load the main calendar-`<div>` with `class="fc-view fc-agendaWeek-view fc-agenda-view"` in order to force the week-view.

I hope, this helps.

Best, guitarman
> 1 votes

# Answer
Thank you for the additional info.

You could easily do this in jquery as follows:

```
$("#calendar").fullCalendar({
  initialView: 'timeGridWeek',
  ...});

```

Fullcalendar Manual
> 0 votes

---
Tags: civievent, calendar
---


# Question
Title: Please help! Uncaught TypeError: CRM.payment is undefined No donations working on CiviCRM Contribute page!
I am still waiting for help on this issue. Please!

# Answer
> 1 votes
Try to disable the CiviCRM firewall extension and test, if the problem persists.

CiviCRM Firewall

There have been issues using this extension in the past, see here.

---
Tags: civicontribute, error, payment-processor
---


# Question
Title: Clean install on WordPress and blank dashboard
After install on WordPress I am getting a blank dashboard and the "configure dashboard" button doesn't do anything. I tried deactivating all plugins except CiviCRM, that made no different. Any ideas what I should look at? All the settings seem to be correct.

# Answer
> 2 votes
I experienced something similar (not sure if the same situation), but I solved it checking database credentials and domain in civicrm\_settings.php on wp-content/uploads/civicrm, may you could check if so.

# Answer
> 1 votes
I discovered an old out of date .htaccess file in the Plugins folder. Deleted that and the CiviCRM dashboard works fine.

# Answer
> 0 votes
Is it possible that your web server user is different from the user who owns the files or ran the installer? You can try deleting your templates\_c folder. Also, check your Developer Tools tab (press F12) for errors, both on the Console and Network tabs. If you find any, please edit your question to include them, they likely contain crucial info.

# Answer
> 0 votes
I found I was looking at the site on a different url than that defined in `civicrm.settings.php` \- the CIVICRM\_UF\_BASEURL - and saw errors in the javascript console.

The dashboard is built dynamically by javascript, and it was trying to connect to the other domain, where I was not logged in.

---
Tags: installation
---


# Question
Title: Multiple Recurring Memberships one Contribution. How to remove 1 membership
We have the option for a user to have their main membership and a second optional add on membership.

We want the user to be able to cancel the optional membership whenever they want.

Currently have built a process to end membership by cancelling recurring contribution via the api. This works well for single memberships or if they want to cancel both.

BUT I want them to just cancel the add on.

I have tried simply removing the 'contribution\_recur\_id' from the membership, but when the billing cycle comes round the full amount is charged and the add on membership is reinstated.

Any ideas or examples of how to manage this?

# Answer
You will need to set the membership status to Cancelled and update the recurring/subscription amount either from CiviCRM or payment gateway based on payment processor you are using.
> 1 votes

---
Tags: civimember, contributions, recurring
---


# Question
Title: CiviCRM API v4 didn't recognized php variable
I was new to CiviCRM, I have the following where %search is a variable in the php, it didn't return anything, is it true that cannot passed parameter in this way? Thanks

$contacts = civicrm\_api4('Contact', 'get', \[ 'select' =\> \[ 'id', 'display\_name', \], 'where' =\> \[ \['OR', \[\['id', 'CONTAINS', $search\], \['display\_name', 'CONTAINS', $search\]\]\], \], 'limit' =\> 25, \]);

# Answer
> 1 votes
It's probably a permissions issue. By default anonymous doesn't have access to contacts, so you either need to add `'checkPermissions' => FALSE` to the parameters or run it as a logged in user with appropriate permissions.

---
Tags: apiv4
---


# Question
Title: What determines the suite of Case Roles presented for assignment on the CIVICRM Webform Case Tab?
When I select a Case Type on the Case tab of the Webform, A suite of Case Roles are presented so a Contact on the CIVICRM tab can be mapped to them. Some of the Roles for the Case Type I selected are not presented. Is there a setting I need to use so all case roles are presented? The one that is missing is an organization contact type we added.

My site is Drupal 7.41, CiviCRM 4.6.10, and Webform CiviCRM Integration module 7.x-4.11.

# Answer
Come to find out that the role not being available to map was because the relationship name and label in the database did not match (i.e. name\_b\_a was "Third cousin once removed" but the label\_b\_a was "Distant cousin"). It seems like when the relationships were originally created we had the ability to set a different name and label - we're guessing this was in an earlier version of CiviCRM as currently the only thing you can add/edit directly in CIvi is the label.

Once the name field was revised to match the label, the role was available for selection in the Cases \> case roles section.
> 4 votes

# Answer
You can add roles to specific case types by going to Administer \> CiviCase \> Case Types, click to edit a given case type and you will see a section for "Roles" where you can add or remove roles as desired.

Roles are actually relationships, so you will need to ensure that you have all of the requisite relationships in place first by going to Administer \> Customize Data and Screens \> Relationship Types.

Hope this helps, Tamar
> 2 votes

# Answer
Now the bug has been fixed in Civi with the label v relationship name, it can still cause frustration - it is very easy to put the relationship in the wrong way around. Even after all these years I still get caught out with Civi's Relationships.

So if you have created a relationship like 'Manager is' and 'Manager for' - if 'Manager is' does not appear on your webform, try adding 'Manager for' in the Case role and see if that shows up. It can be a real gotcha depending on how you have set up the relationship.
> 0 votes

---
Tags: webform-civicrm
---


# Question
Title: Errors when trying to process CiviCRM contribution with BackdropCMS
Using CiviCRM with Backdrop CMS. The site is running 5.59.3.

When we try to process a transaction we were getting this error: `Session invalid. Please reload and try again`

See: https://forum.backdropcms.org/forum/backdropcivicrm-error-session-invalid-please-reload-and-try-again

After playing around with this and updating CiviCRM, we are now getting this error when processing a transaction:

`Sorry an error occurred and your request was not completed. (Error ID: cumu-Jnkb-MjLE)`

The Backdrop LOG gives us this:

```
AJAX Error ({error_id}): failed with exception Array ( [error_id] => cumu-Jnkb-MjLE [exception] => CRM_Core_Exception: "Bad Request"
#0 /var/www/---/prod/src/web/modules/civicrm/Civi/Api4/Provider/ActionObjectProvider.php(72): Civi\Api4\Action\StripePaymentintent\ProcessPublic->_run()
#1 /var/www/---/prod/src/web/modules/civicrm/Civi/API/Kernel.php(158): Civi\Api4\Provider\ActionObjectProvider->invoke()
#2 /var/www/---/prod/src/web/modules/civicrm/Civi/Api4/Generic/AbstractAction.php(250): Civi\API\Kernel->runRequest()
#3 /var/www/---/prod/src/web/modules/civicrm/api/api.php(85): Civi\Api4\Generic\AbstractAction->execute()
#4 /var/www/---/prod/src/web/modules/civicrm/CRM/Api4/Page/AJAX.php(138): civicrm_api4()
#5 /var/www/---/prod/src/web/modules/civicrm/CRM/Api4/Page/AJAX.php(79): CRM_Api4_Page_AJAX->execute()
#6 /var/www/---/prod/src/web/modules/civicrm/CRM/Core/Invoke.php(319): CRM_Api4_Page_AJAX->run()
#7 /var/www/---/prod/src/web/modules/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem()
#8 /var/www/---/prod/src/web/modules/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke()
#9 /var/www/---/prod/src/web/modules/civicrm/backdrop/civicrm.module(551): CRM_Core_Invoke::invoke()
#10 /var/www/---/prod/src/web/core/includes/menu.inc(584): civicrm_invoke()
#11 /var/www/---/prod/src/web/core/modules/layout/layout.module(639): menu_default_route_handler()
#12 /var/www/---/prod/src/web/core/includes/menu.inc(531): layout_route_handler()
#13 /var/www/---/prod/src/web/index.php(21): menu_execute_active_handler() #14 {main} )

```

# Answer
> 0 votes
Session issues can be related to mixed http/https www.example.com/example.com. Check your browser console network tab and ensure they are all consistent.

---
Tags: civicontribute, stripe, backdrop
---


# Question
Title: Why am I getting "Mismatched contact type." when I try to import any contacts?
Wordpress 6.1.1, Civi 5.59.4

I have been getting the error "Mismatched contact type." which is possibly linked to this: https://lab.civicrm.org/dev/core/-/issues/3927 but that appears patched since 5.54

I cannot replicate in demo master.

However I noticed that the dedupe rule options do not change based on contact type selection, they all show up.

When I select the right dedupe rule - it imports without issue.

# Answer
> 2 votes
This is fixed by https://github.com/civicrm/civicrm-core/pull/25515/files in 5.60.

```
--- a/CRM/Contact/Page/AJAX.php
+++ b/CRM/Contact/Page/AJAX.php
@@ -483,7 +483,7 @@ public static function buildSubTypes() {
   }

   public static function buildDedupeRules() {
-    $contactType = CRM_Utils_Request::retrieve('parentId', 'Positive');
+    $contactType = CRM_Utils_Request::retrieve('parentId', 'String');
     $dedupeRules = CRM_Dedupe_BAO_DedupeRuleGroup::getByType($contactType);

     CRM_Utils_JSON::output($dedupeRules);

```

---
Tags: contacts, import, data-import
---


title: Adding permissions for SearchKit forms

text:
# Question
Title: Adding permissions for SearchKit forms
I suspect the answer is 'you'll have to code it...', but SearchKit has advanced so rapidly, I thought it was worth asking the question.

I have a search form that I need to secure for a certain group of users. ACLs do just about everything I need along with Drupal permissions/roles. I want to be able to control access to a SearchKit form, but the only way I can do this by the looks of it is to choose a particular CiviCRM permission?

The ideal way would be to make it consistent with the rest of CiviCRM and control it through ACLs - at the moment you can choose to secure groups of contacts, profiles, custom data and events, but not unfortunately anything related to SearchKit/Afform.

So do I have use a hook\_civicrm\_permission to create the particular permissions I need?

# Answer
I think you are correct that SearchKit permissions don't integrate with ACL's yet.

Maybe you could create a permission for your form, grant it to your Drupal role and configure SK to use it. I don't think your extension would need to do anything more than define the permission with `hook_civicrm_permission()`.
> 2 votes

---
Tags: searchkit
---


# Question
Title: Using a Token to Pull Only the Year from a Date
I'm trying to set up membership renewal reminder letters, and instead of including the entire date that the member joined, we'd like it to just be the year. I have a token for "latestcurrentmembership.join\_date" that adds that date as "January 1, 2022." Is there a way to have the token only add "2022" to the letter?

# Answer
> 1 votes
I had been looking for something similar and wanted to follow up for anyone reading this post. (I would have left a comment on Demerit's answer but wanted to include a tad more info.)

I could not get the token modifiers listed to work in Civi 5.57.4 on Drupal 7, PHP 8.025 (even though it says they work in 5.43 and up, perhaps I have some customization causing a conflict).

I was able to get them to work on the Dmaster today though - it is running 5.61.alpha1 on Drupal 7 and PHP 7.4.33. I found that you can use those for core date but not custom date fields, here's a printout:

```
Date of birth
{contact.birth_date} : December 1st, 1980
{contact.birth_date|crmDate:"Year"} : 1980

Custom Date token
{contact.custom_3} : 03/01/2023
{contact.custom_3|crmDate:"Year"} : 03/01/2023

```

I'm guessing that the fact that the custom date token formats differently out of the gate is part of the reason it doesn't work.

For fun, I also tried the smarty modifier |date\_format:"%Y" but that produces an error: Invalid token filter: \["date\_format","%Y"\] so they've shored up that part of the code to help show errors.

---

Additional information based on Demerit's comments. While the crmDate token modifiers didn't work for a custom field Demerit was spot on.

> For the custom one, if you know the date format is always mm/dd/yyyy, you could do {capture assign=foo}{contact.custom\_3}{/capture}{$foo|substring:6:4}, and actually I don't think you need the capture, just some quotes: {"{contact.custom\_3}"|substring:6:4}

The capture method worked perfectly for me.

# Answer
> 0 votes
It *might* work to use crmDate as described at https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/#date, i.e.

`{latestcurrentmembership.join_date|crmDate:"Year"}`

However not everything listed there works everywhere in all versions so I don't know offhand if that works in your version of civi in scheduled reminders. Only one way to find out!

---
Tags: civimail, civimember, tokens
---


# Question
Title: "Error: CRM.url called before initialization" on contribution page
I am getting this - "Error: CRM.url called before initialization" when I select the country from 'country field' included in the profile.

Steps to replicate:

> * Created a profile including address fields street, pincode, country, states, city
> * created a contribution page.
> * added profile for that contribution page.
> * Opened "contribution link" for live mode.
> * Try to change the country name state/province field keep spinning.

What will be the issue?

reference file:civicrm/js/crm.ajax.js

# Answer
Came across this annoying error after installing webform\_civicrm on Drupal 9 and testing a donation.

It was simply a case of running the `cv flush` command followed by `drush cr`

Hope this helps!
> 0 votes

---
Tags: profile, contribution-page, addresses
---


# Question
Title: Add Amex to credit cards accepted in iATS payment processor
iATS confirmed that they can accept AMEX, but the extension only provides VISA Mastercard and Discover. How can we add AMEX?

# Answer
The extension accepts AMEX, but you may have configured things such that your CiviCRM does not -\> /civicrm/admin/options/accept\_creditcard?reset=1
> 3 votes

---
Tags: iats, iatspayments
---


# Question
Title: Membership Form - Remove Link under Membership Type
We have a link under one of our membership types on our membership sign up form and I am having trouble finding where the URL was created. It needs to be removed. Thank you!

# Answer
You may have some HTML in the Price Option of a Price Set that is in use on your Membership tab of the Contribution Page.

Go to /civicrm/admin/contribute?reset=1

Find relevant Contribution Page, click through to its Membership tab. Scroll down to find the name of the Price set. Then find this in the list of your Price Sets (at bottom of Contribution menu).

Then do a Preview, confirm the issue is showing there, find the right Price Option and remove as required.
> 0 votes

---
Tags: civimember
---


# Question
Title: Is there a way in a custom report to only give the user certain choices in filters, e.g. only show them groups that belong to a parent group?
I've written a custom report, lots of trial and mostly error. One of the columns is group. Since we have almost 300 groups, I'd like to limit the groups the user can include in the report to a subset. (Only certain groups make sense with this report and no one wants to wade through 300 groups to find the several they want.)

Clearly using filters in the \_columns is the way to go but I'm not sure just what to put where. I've found examples of hard coded values but I'd like a bit of sql. Maybe there are some examples that my grep didn't find of sql statements.

Here is the basic sql I'd like to use. Maybe it only needs to return the id instead of the title.

`select g.title from civicrm_group g, civicrm_group_nesting n where g.id = n.child_group_id and parent_group_id in (124, 125)`

The report already limits the groups to these but users may only want one or two groups and not the full 20 or so groups the defaults return.

# Answer
It turns out the filters option of the \_columns is what I wanted, but civicrm\_group is bit of a special case. The problem I finally stumbled upon is at the end of the \__construct function is a call to parent::\__construct(). (I have a lot of columns defined, so for me it is a ways down so I didn't see it right away.) That ends up overwriting what I had in the filter for civicrm\_group. Right above this call, two variables get set to TRUE, \_groupFilter and \_tagFilter. Setting the groupFilter to false prevents the parent construct from overwriting it.

So for completeness in the answer I'll give what code I ended up with for what it's worth.

So at the top of the function \__construct I have this. There are probably better ways to do this:

```
  $sql = "select id, title
          from civicrm_group g
          where g.id in (
              select n.child_group_id
              from   civicrm_group_nesting n
              where  n.parent_group_id in (124,125))
          order by title";

$dao = CRM_Core_DAO::executeQuery($sql);

while ($dao->fetch()) {
  $MyGroups[$dao->id] = $dao->title;
}

```

then in the filter section of \_columns for group I have this

```
     'filters' => array(
        'gid' => array(
        'name' => 'group_id',
        'title' => E::ts('My Groups'),
        'operatorType' => CRM_Report_Form::OP_MULTISELECT,
        'type' => CRM_Utils_Type::T_INT,
        'options' => $MyGroups,
        ),
      ),

```
> 1 votes

---
Tags: custom-reports
---


title: DB error: Already Exists

text:
# Question
Title: DB error: Already Exists
Using Civi 5.20.3 Contacts are getting an error (DB error: Already Exists) when filling out a profile form. This is what I saw on the Drupal Watchdog. What does it mean?

$Fatal Error Details = Array ( \[callback\] =\> Array ( \[0\] =\> CRM\_Core\_Error \[1\] =\> handle ) \[code\] =\> -5 \[message\] =\> DB Error: already exists \[mode\] =\> 16 \[debug\_info\] =\> UPDATE civicrm\_cache SET data = .....

created\_date = FROM\_UNIXTIME(1581961411), expired\_date = FROM\_UNIXTIME(1581983012) WHERE group\_name = "contact-20fields" AND path = "exportableFields All\_0\_0\_0\_" \[nativecode=1062 \** Duplicate entry 'contact-20fields-exportableFields All\_0\_0\_0\_-2020-02-17 11:43:31' for key 'UI\_group\_path\_date'\] \[type\] =\> DB\_Error \[user\_info\] =\> UPDATE civicrm\_cache SET data

# Answer
> 1 votes
While it's hard to tell without the entire error message it looks like given that the query appears to be an update to a cache table I'd recommend clearing your caches.

drush cc all or via /civicrm/admin/setting/updateConfigBackend?reset=1

# Answer
> 1 votes
It happened to me on a website with Drupal and CiviCRM. I had no access to drush. I have done a truncate of the civicrm\_cache table, and it has been enough to solve the problem.

---
Tags: error
---


# Question
Title: Selecting Payment Processor other than PayPal Pro shuts down Payment Processor setup window
This seems like a fundamental question, but I have searched and not found anything similar. Please excuse me if I have missed it.

Having successfully used 'PayPal - website payments standard' as payment processor in CiviCRM/Drupal 7 for many years, I am having difficulty setting it up in CiviCRM/Backdrop instance. I wonder if someone might understand what is happening here: At very first setup instance, selecting anything but 'PayPal - website payments pro', including Dummy Payment Processor, simply closes the setup window and returns me to the (empty) Payment processor list. PayPal - Website Payments Pro allows me to enter details and save that option (though client does not have a Pro account).

**Environment**: Backdrop CMS 1.24.0 **MySQL Database**: MySQL, MariaDB, or equivalent version 5.5.5-10.4.20-MariaDB-1:10.4.20+maria~buster-log **PHP Version**: 7.4.33 **Web server**: Apache/2.4.56 (Debian) **CiviCRM** 5.58.1

# Answer
> 1 votes
Updated Backdrop to 1.24 and CiviCRM to 5.59.4 and all processors now available and work.

---
Tags: payment-processor, paypal, backdrop
---


title: cv upgrade:db causes error

text:
# Question
Title: cv upgrade:db causes error
When I try to upgrade via cv, I get the following error:

```
In DrupalBase.php line 282:

[Error] Call to undefined function _drupal_flush_css_js()

```

I am able to do the upgrade within the GUI.

Any thoughts?

Verbose listing:

```
~/p$ cv -vvv upgrade:db

Box Requirements Checker
========================

> Using PHP 8.1.13
> PHP is using the following php.ini file:
  /usr/local/php81/lib/php.ini

> Checking Box requirements:
  ✔ The application requires a version matching ">=7.3.0".
  ✔ The application requires the extension "json".
  ✔ The package "psy/psysh" requires the extension "json".
  ✔ The package "jakub-onderka/php-console-highlighter" requires the extension "tokenizer".
  ✔ The package "nikic/php-parser" requires the extension "tokenizer".
  ✔ The package "psy/psysh" requires the extension "tokenizer".

 [OK] Your system is ready to run the application.

[BootTrait] Start
[BootTrait] Attempting to set verbose error reporting
[BootTrait] Call standard cv bootstrap
[Bootstrap] Options: {
    "dynamicSettingsFile": "phar:///home/myuser/vendor/bin/cv/settings_location.php",
    "env": "CIVICRM_SETTINGS",
    "prefetch": true,
    "settingsFile": null,
    "search": true,
    "cmsType": null,
    "httpHost": "",
    "output": {}
}
[Bootstrap] Find settings file
[Bootstrap] Load supplemental configuration for "/home/myuser/p/sites/default/civicrm.settings.php"
[Bootstrap] Find CMS root for "/home/myuser/p"
[Bootstrap] Found "drupal" in "/home/myuser/p"
[Bootstrap] Simulate web environment in CLI
[Bootstrap] Load settings file "/home/myuser/p/sites/default/civicrm.settings.php"
[Bootstrap] Initialize class loader
[Bootstrap] Call core bootstrap

In DrupalBase.php line 282:

  [Error]
  Call to undefined function _drupal_flush_css_js()

Exception trace:
  at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Utils/System/DrupalBase.php:282
 CRM_Utils_System_DrupalBase->clearResourceCache() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Core/Resources.php:362
 CRM_Core_Resources->resetCacheCode() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Core/Resources.php:138
 CRM_Core_Resources->__construct() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/Civi/Core/Container.php:557
 Civi\Core\Container::createResources() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/vendor/symfony/dependency-injection/ContainerBuilder.php:1130
 Symfony\Component\DependencyInjection\ContainerBuilder->createService() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/vendor/symfony/dependency-injection/ContainerBuilder.php:618
 Symfony\Component\DependencyInjection\ContainerBuilder->doGet() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/vendor/symfony/dependency-injection/ContainerBuilder.php:558
 Symfony\Component\DependencyInjection\ContainerBuilder->get() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/Civi.php:175
 Civi::service() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Core/Resources.php:116
 CRM_Core_Resources::singleton() at /home/myuser/domains/mydomain/public_html/sites/default/files/civicrm/ext/nz.co.fuzion.environmentindicator/environmentindicator.php:13
 environmentindicator_civicrm_config() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Utils/Hook.php:271
 CRM_Utils_Hook->runHooks() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Utils/Hook/DrupalBase.php:73
 CRM_Utils_Hook_DrupalBase->invokeViaUF() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php:306
 Civi\Core\CiviEventDispatcher::delegateToUF() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php:251
 Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php:73
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/Civi/Core/CiviEventDispatcher.php:260
 Civi\Core\CiviEventDispatcher->dispatch() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Utils/Hook.php:167
 CRM_Utils_Hook->invoke() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Utils/Hook.php:1382
 CRM_Utils_Hook::config() at /home/myuser/domains/mydomain/public_html/sites/all/modules/civicrm/CRM/Core/Config.php:94
 CRM_Core_Config::singleton() at phar:///home/myuser/vendor/bin/cv/src/Bootstrap.php:104
 Civi\Cv\Bootstrap->boot() at phar:///home/myuser/vendor/bin/cv/src/Util/BootTrait.php:69
 Civi\Cv\Command\UpgradeDbCommand->_boot_full() at phar:///home/myuser/vendor/bin/cv/src/Util/BootTrait.php:44
 Civi\Cv\Command\UpgradeDbCommand->boot() at phar:///home/myuser/vendor/bin/cv/src/Command/UpgradeDbCommand.php:31
 Civi\Cv\Command\UpgradeDbCommand->execute() at phar:///home/myuser/vendor/bin/cv/vendor/symfony/console/Command/Command.php:127
 Cvphar\Symfony\Component\Console\Command\Command->run() at phar:///home/myuser/vendor/bin/cv/vendor/symfony/console/Application.php:637
 Cvphar\Symfony\Component\Console\Application->doRunCommand() at phar:///home/myuser/vendor/bin/cv/vendor/symfony/console/Application.php:190
 Cvphar\Symfony\Component\Console\Application->doRun() at phar:///home/myuser/vendor/bin/cv/src/Application.php:66
 Civi\Cv\Application->doRun() at phar:///home/myuser/vendor/bin/cv/vendor/symfony/console/Application.php:101
 Cvphar\Symfony\Component\Console\Application->run() at phar:///home/myuser/vendor/bin/cv/src/Application.php:32
 Civi\Cv\Application::main() at phar:///home/myuser/vendor/bin/cv/bin/cv:28
 require() at /home/myuser/vendor/bin/cv:14

upgrade:db [--out OUT] [--flat [FLAT]] [--dry-run] [--retry] [--skip] [--step] [--level LEVEL] [--hostname HOSTNAME] [-t|--test] [-U|--user USER]

```

# Answer
It sounds drupal hasn't had a chance to boot yet before that gets called. Try disabling the environmentindicator extension first, since it's calling it during hook\_config which might be too early here.
> 0 votes

---
Tags: upgrade, cv
---


title: File on case no longer works by Case ID

text:
# Question
Title: File on case no longer works by Case ID
I've been testing CiviCRM 5.57.4 and noticed that I can no longer type in the Case ID when searching for the case to file an activity to. (I'm in Drupal 7) In version 5.45.7 it was still working. I verified that on dmaster it also does not work - I did create a case or two to test with since the sample data doesn't include cases.

I don't see any changes to the core file Case/Form/ActivityToCase.php that jump out at me as the cause. Does anyone know where else I could take a peek?

# Answer
> 1 votes
Update: Fix is at https://github.com/civicrm/civicrm-core/pull/25982

---

Git bisect says it is caused by https://github.com/civicrm/civicrm-core/pull/24727/commits/f40da46a0dd2d7f8bdb5ed2ff3a453b527ebef94. I'll update the lab ticket.

---
Tags: civicase, activities
---


# Question
Title: Migrating drupal 7 civicrm webforms to drupal 9 civicrm webforms
What is the best way of approaching this such that I can avoid having to rebuild the forms manually - especially if I have a lot of forms.

# Answer
> 1 votes
If only a couple of forms then it may be simpler to just rebuild but if you want to migrate you could look at using https://github.com/fuzionnz/webform\_civicrm\_migrate and https://github.com/fuzionnz/webform\_migrate\_plus.

Both modules are under ongoing refinements - definitely backup before using.

(for more about migrating civicrm from d7 to d9 read: Moving existing CiviCRM to new Drupal instance + upgrade to Drupal 9)

---
Tags: webform-civicrm, migration
---


# Question
Title: Error "HTTP 401 Invalid credential" on dev site (Basic HTTP Auth issue)
After resyncing the database from live to dev I hit the above error on any CiviCRM paths.

# Answer
> 3 votes
From https://github.com/civicrm/civicrm-core/pull/22837

In case future me or someone else hits this again hopefully this will provide a solution.

On dev site which is **behind basic http auth** you can run:

cv vset authx\_header\_cred=\[\]

If you are hitting this error not on a dev site / behind Basic Http Auth then you probably have a different problem.

---
Tags: untagged
---


title: Search Kit fatal error

text:
# Question
Title: Search Kit fatal error
WP 5.7.8 PHP 8.0.26 civi 5.51.1 Search kit 5.51.1

Any search - I tested with simple contact = type individual, reports no result. Civi screen stays the same ie no error message just no result.

Unfortunately I can't upgrade due to Kinsta issues (see other thread ServiceNotFoundException for "spec\_gatherer" on CiviCRM 5.55+ when hosting with Kinsta )

Error 1=

```
2023/03/27 05:10:50 [error] 114740#114740: *646 FastCGI sent in stderr:
"PHP message: PHP Fatal error: Uncaught TypeError:
Civi\Api4\Action\SearchDisplay\Run::processResult(): Argument #1 ($result)
must be of type Civi\Api4\Result\SearchDisplayRunResult,
Civi\Api4\Generic\Result given,
called in /www/invasives_235/public/wp-content/plugins/civicrm/civicrm/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php on line 114
and defined in /www/invasives_235/public/wp-content/plugins/civicrm/civicrm/ext/search_kit/Civi/Api4/Action/SearchDisplay/Run.php:37

```

Stack trace:

```
#0 /www/####/public/wp-content/plugins/civicrm/civicrm/ext/search_kit/Civi/Api4/Action/SearchDisplay/AbstractRunAction.php(114):
Civi\Api4\Action\SearchDisplay\Run->processResult(Object(Civi\Api4\Generic\Result))
#1 /www/####/public/wp-content/plugins/civicrm/civicrm/Civi/Api4/Provider/ActionObjectProvider.php(69):
Civi\Api4\Action\SearchDisplay\AbstractRunAction->_run(Object(Civi\Api4\Generic\Result))
#2 /www/#####/public/wp-content/plugins/civicrm/civicrm/Civi/API/Ker" while reading response header from upstream, client: 125.168.64.134, server: env-#####-pushciviug.kinsta.cloud, request: "POST /wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fajax%2Fapi4 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php8.0-fpm-#####.sock:", host: "env-###-pushciviug.kinsta.cloud:26165", referrer: "https://env-#####-pushciviug.kinsta.cloud/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin%2Fsearch"

```

and browser errors are:

```
jquery.min.js:4          POST https://env-#####-pushciviug.kinsta.cloud/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fajax%2Fapi4 500
send @ jquery.min.js:4
ajax @ jquery.min.js:4
n.<computed> @ jquery.min.js:4
(anonymous) @ crm.ajax.js?r=Pt4f9en_AU:85
CRM.api4 @ crm.ajax.js?r=Pt4f9en_AU:72
crmApi4 @ angular-modules.af5fd05bc138b0651c13190765a8f2df.js:17
runSearch @ angular-modules.af5fd05bc138b0651c13190765a8f2df.js:3909
(anonymous) @ angular-modules.af5fd05bc138b0651c13190765a8f2df.js:3819
$eval @ angular.js:19523
$apply @ angular.js:19622
(anonymous) @ angular-modules.af5fd05bc138b0651c13190765a8f2df.js:3818
e @ lodash.min.js:40
setTimeout (async)
o @ lodash.min.js:41
onClickSearchButton @ angular-modules.af5fd05bc138b0651c13190765a8f2df.js:3895
fn @ VM7696:4
e @ angular.js:29123
$eval @ angular.js:19523
$apply @ angular.js:19622
(anonymous) @ angular.js:29127
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
angular.js:15697 TypeError: Cannot read properties of undefined (reading 'debug')
    at controller.<anonymous> (angular-modules.af5fd05bc138b0651c13190765a8f2df.js:3163:71)
    at angular-modules.af5fd05bc138b0651c13190765a8f2df.js:3936:22
    at qt (lodash.min.js:9:507)
    at Function.Re (lodash.min.js:37:336)
    at angular-modules.af5fd05bc138b0651c13190765a8f2df.js:3935:13
    at angular.js:18075:37
    at m.$digest (angular.js:19242:15)
    at angular.js:19562:15
    at Yg.completeTask (angular.js:21403:7)
    at angular.js:6879:7 'Possibly unhandled rejection: {}'

```

# Answer
Kinsta hosting caching was the issue. Search Kit worked once they enabled opcache.save\_comments in the Nginx server cache
> 1 votes

---
Tags: searchkit
---


# Question
Title: ServiceNotFoundException for "spec_gatherer" on CiviCRM 5.55+ when hosting with Kinsta
with recent versions of CiviCRM (WordPress), I am getting fatal errors for all back-end/wp-admin requests, when hosting with Kinsta.com, related to an unhandled Service Not Found Exception within Civi.

I have been running CiviCRM on this client's website (WordPress) for 6+ years, and have generally updated CiviCRM every 2 months. This site has been at Kinsta for 4+ years, so this isn't anything to do with changing hosts.

Today I updated from Civi 5.54.2 to 5.57.2. It worked in my local dev (workstation) environment, and the staging environment at Kinsta. But when pulling the updates to production (via git - code is identical), I started getting fatal errors.

Working with Kinsta support, we determined the difference between staging and production was that Kinsta's internal caching system was enabled in production but not staging.

Further, in both environments, with Kinsta caching disabled, everything works. When it is enabled, we get the fatal errors.

So this clearly has something to do with the Kinsta caching system, but not entirely. When I revert to Civi 5.54.2, everything works again. (I also tried 5.56.2 and 5.55.2 but they also had errors.)

PHP error details are below.

Can anyone think of what might have changed in Civi and the Services components (and maybe "spec\_gatherer" in particular) between 5.54 and 5.55 which might cause conflicts with some nginx caching scheme?

Thank you!

```
PHP Fatal error:  Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "spec_gatherer". in /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/vendor/symfony/dependency-injection/ContainerBuilder.php:1030
Stack trace:
#0 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/Civi/Core/Compiler/SpecProviderPass.php(16): Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition('spec_gatherer')
#1 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/vendor/symfony/dependency-injection/Compiler/Compiler.php(94): Civi\Core\Compiler\SpecProviderPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#2 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/vendor/symfony/dependency-injection/ContainerBuilder.php(762): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#3 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/Civi/Core/Container.php(79): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#4 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/Civi/Core/Container.php(640): Civi\Core\Container->loadContainer()
#5 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/CRM/Core/Config.php(87): Civi\Core\Container::boot(true)
#6 /www/hajotuxu_393/public/wp-content/plugins/civicrm/includes/civicrm.admin.php(434): CRM_Core_Config::singleton()
#7 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm.php(972): CiviCRM_For_WordPress_Admin->initialize()
#8 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm.php(794): CiviCRM_For_WordPress->initialize()
#9 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm.php(767): CiviCRM_For_WordPress->register_hooks_clean_urls()
#10 /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm.php(651): CiviCRM_For_WordPress->register_hooks_common()
#11 /www/hajotuxu_393/public/wp-includes/class-wp-hook.php(308): CiviCRM_For_WordPress->register_hooks('')
#12 /www/hajotuxu_393/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#13 /www/hajotuxu_393/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#14 /www/hajotuxu_393/public/wp-settings.php(617): do_action('init')
#15 /www/hajotuxu_393/public/wp-config.php(121): require_once('/www/hajotuxu_3...')
#16 /www/hajotuxu_393/public/wp-load.php(50): require_once('/www/hajotuxu_3...')
#17 /www/hajotuxu_393/public/wp-admin/admin.php(34): require_once('/www/hajotuxu_3...')
#18 /www/hajotuxu_393/public/wp-admin/index.php(10): require_once('/www/hajotuxu_3...')
#19 {main}
  thrown in /www/hajotuxu_393/public/wp-content/plugins/civicrm/civicrm/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1030

```

# Answer
For us Kinsta hosting caching was the issue. Able to upgrade once they enabled opcache.save\_comments in the Nginx server cache
> 2 votes

# Answer
I had the same problem. I had changed some of the php settings:

* expose\_php = off
* magic\_quotes\_gpc = off
* register\_globals = off

When I commented these out everything worked. An after removing the comments it kept working.

This returned when clearing caches. So it is not solved yet.

It might be a PHP 8.1 incompatibility. Reverted to 7.4.
> 1 votes

# Answer
I'm also getting the error about spec\_gatherer while trying to upgrade from CiviCRM 5.35.1 to 5.58.1 on a Drupal7 + PHP 7.3 environment.

> Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "spec\_gatherer". in Symfony\Component\DependencyInjection\ContainerBuilder-\>getDefinition() (line 1030 /var/www/XXX/sites/all/modules/civicrm/vendor/symfony/dependency-injection/ContainerBuilder.php).

Disabling expose\_php, magic\_quotes\_gpc, register\_globals had no effect.

Has anyone found a solution for this problem?
> 0 votes

---
Tags: cache, webserver, symfony
---


# Question
Title: transfer from wordpress to drupal > profile form not working
My "Sign up for newsletter" form was working on Wordpress. I recently moved to Drupal and now I am getting the error message below. Of the 4 possible errors, the profile is enabled, there is a Profile with that ID.

So the problem seems to be either the Profile is "not configured to be used for 'Profile' listings in its Settings" or there is a permissions problem.

How do I resolve either of these in Drupal?

The requested Profile (gid=15) is disabled OR it is not configured to be used for 'Profile' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.

# Answer
> 1 votes
> either the Profile is "not configured to be used for 'Profile' listings in its Settings"

this is resolved in Drupal in exact same way as WP, in the Settings section of the Profile

> or there is a permissions problem

I don't assume you are asking 'where do I set permissions in Drupal' but that seems like the only answer I can give - look under People in the drupal admin menu. If the Profile contains custom fields then make sure you have also set the permission for these, but in theory these are all much the same in WP I believe

Otherwise happy to try answering again if you can finesse your question.

---
Tags: drupal, profile
---


# Question
Title: Why are SearchKit links blank if a data item is missing?
I am recreating some Drupal Views in SearchKit and it has gone well except for one thing - links. I'm not sure if what I am experiencing is a feature or a bug hence the question.

Our Views allow a user to click on a link that takes them to a Drupal Webform, often to complete or continue a process. The link uses various data items such as Contact IDs and Activity IDs to populate the target form.

If I create what is effectively the same View in SearchKit the link will not be output if any data item or items in the link is/are missing (and it may well be null at that point for good reasons).

To illustrate, lets say I have a link defined like this:

```
civicrm/my_form?case1=[id]&cid2=[some_contact]&cid3=[another_contact]&activity1=[some_activity]

```

If, say, cid3 has no data for that record, the entire link will not be displayed in either a list or a table for that particular line. A drupal View will just pass the link on with cid3 having no data, which is fine for our purposes: `civicrm/my_form?case1=1234&cid2=123456&cid3=&activity1=54321`

I have tried experimenting with the 'Show if' but whatever I put there, that line never displays. As an example I set the Show if to display if the case ID was \> 1 (it always would be on a View that displays cases) but this had no effect.

Am I missing a setting somewhere?

# Answer
That sounds like an oversight or scenario that hasn't been tested. Create an issue at https://lab.civicrm.org/dev/core/-/issues
> 1 votes

---
Tags: searchkit
---


# Question
Title: Discount Code applying to more than the one specified price field
I have multiple discount codes set up for my event fees. One of which is applying a fixed amount I specified for only one price field to two fields instead. It's the only code misbehaving. It essentially applies the same dollar amount discount to a price field I didn't include in the code set up. I've tried recreating the code with another name, and changing the fee amount for one (since both fields are the same price?). Any help appreciated!

# Answer
This may help, perhaps?

https://lab.civicrm.org/extensions/cividiscount/-/issues/295#note\_87867

It does not solve the issue when two discounts are applied to two different price field options or even two different price fields on the same price set. If this is not an issue for you, the above patch should work.
> 1 votes

---
Tags: cividiscount
---


title: Truncating text fields in searchkit

text:
# Question
Title: Truncating text fields in searchkit
I'm building lists of incoming enquiries/referrals for our services.

Info comes in from a webform, and includes a text field to capture details of reasons for referral/ contact need.

Some of these statements of need can be minor essays, and makes the incoming referral list difficult to use.

Is there a way to truncate the amount of text that appears in the table listing? Say max number of words/ characters?

# Answer
> 3 votes
You could try {'\[Referral\_Details.Further\_Details\]'|truncate} (will limit to default 80 characters) or {'\[Referral\_Details.Further\_Details\]'|truncate:30} to set the number of characters.

---
Tags: searchkit
---


# Question
Title: How can I resolve what seems to be a timezone-related error?
I am running CiviCRM 5.59.2 on Wordpress 6.2.

I am getting an occasional error in CiviCRM that I think has something to do with a timezone not being set correctly somewhere. In my Wordpress general settings, the timezone is set to Vancouver which is where the client is located. But the error suggests that somewhere the timezone is set to Berlin. Or, perhaps, I am misunderstanding this. I'm not a programmer :-)

I have spent quite a lot of time trying to figure this out, but obviously I haven't.

Can anyone please help me learn how to fix this? The more specific the instructions the better :-)

Thanks!

This is the error from the CiviCRM log:

```
[error] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => exceptionHandler
        )

    [code] => -14
    [message] => DB Error: no database selected
    [mode] => 16
    [debug_info] => SET time_zone = '-7:00' [nativecode=2006 ** MySQL server has gone away]
    [type] => DB_Error
    [user_info] => SET time_zone = '-7:00' [nativecode=2006 ** MySQL server has gone away]
    [to_string] => [db_error: message="DB Error: no database selected" code=-14 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="SET time_zone = '-7:00' [nativecode=2006 ** MySQL server has gone away]"]
)

```

This is the backtrace from the CiviCRM log:

```
bug] $backTrace = #0~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(954): CRM_Core_Error::backtrace("backTrace", TRUE)
#1~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(945): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#2~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB.php(997): PEAR_Error->__construct("DB Error: unknown error", -1, 16, (Array:2), "SET @@time_zone = \"Europe/Berlin\" [nativecode=1298 ** Unknown or incorrect ...")
#3~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-1, 16, (Array:2), "SET @@time_zone = \"Europe/Berlin\" [nativecode=1298 ** Unknown or incorrect ...")
#4~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR::_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "SET @@time_zone = \"Europe/Berlin\" [nativecode=1298 ** Unknown or incorrect ...", "DB_Error", TRUE)
#5~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php(1928): PEAR->__call("raiseError", (Array:7))
#6~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php(943): DB_common->raiseError(-1, NULL, NULL, "SET @@time_zone = \"Europe/Berlin\" [nativecode=1298 ** Unknown or incorrect ...", "1298 ** Unknown or incorrect time zone: 'Europe/Berlin'")
#7~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php(413): DB_mysqli->mysqliRaiseError()
#8~/public_html/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php(1234): DB_mysqli->simpleQuery("SET @@time_zone = \"Europe/Berlin\"")
#9~/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2696): DB_common->query("SET @@time_zone = \"Europe/Berlin\"")
#10~/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("SET @@time_zone = \"Europe/Berlin\"")
#11~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(494): DB_DataObject->query("SET @@time_zone = \"Europe/Berlin\"")
#12~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1749): CRM_Core_DAO->query("SET @@time_zone = \"Europe/Berlin\"", TRUE)
#13~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Check/Component/Timestamps.php(39): CRM_Core_DAO::singleValueQuery("SET @@time_zone = \"Europe/Berlin\"")
#14~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Check/Component.php(76): CRM_Utils_Check_Component_Timestamps->checkTimezoneAPIs(FALSE)
#15~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Check.php(215): CRM_Utils_Check_Component->checkAll((Array:0), FALSE)
#16~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Check.php(185): CRM_Utils_Check::checkStatus()
#17~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Check.php(93): CRM_Utils_Check::checkAll()
#18~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Page.php(255): CRM_Utils_Check->showPeriodicAlerts()
#19~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contact/Page/DashBoard.php(57): CRM_Core_Page->run()
#20~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(319): CRM_Contact_Page_DashBoard->run((Array:2), NULL)
#21~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem((Array:17))
#22~/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:2))
#23~/public_html/wp-content/plugins/civicrm/civicrm.php(1199): CRM_Core_Invoke::invoke((Array:2))
#24~/public_html/wp-includes/class-wp-hook.php(308): CiviCRM_For_WordPress->invoke("")
#25~/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters("", (Array:1))
#26~/public_html/wp-includes/plugin.php(517): WP_Hook->do_action((Array:1))
#27~/public_html/wp-admin/admin.php(259): do_action("toplevel_page_CiviCRM")
#28 {main}

```

# Answer
Visit the civi system status check page. It will give you a link to https://dev.mysql.com/doc/refman/8.0/en/mysql-tzinfo-to-sql.html. If you can't do that, civi will still work for the foreseeable future. Also when you upgrade to 5.61 the extra logging will go away.
> 1 votes

---
Tags: error, timezone
---


# Question
Title: Caldera Forms access plugin options/admin page without accessing other plugins
I understand that Caldera Forms was sunset a while ago, but that there is a version still available for CiviCRM, which I am using.

On WordPress, I have some CiviCRM users that I want to also be able to access the Caldera Forms plugin/admin page, but this would require giving them the manage\_options capability which would then allow them access to ALL plugins, which I do not want.

How can I grant them access to Caldera Forms plugin only, without having access to other plugins?

# Answer
> 1 votes
We can use the caldera forms caldera\_forms\_manage\_cap hook to grant access to specific users without giving them access to any other plugins.

In order for this solution to work, you will need to install two addtional plugins:

MEMBERS PLUGIN

Once Members is installed and activated, go to the Members SETTINGS page and check the Multiple User Roles box "Allow users to be assigned more than a single role."

Go to Members ADD NEW ROLE and create a new role called "Caldera Forms Access". This new role should only have 1 capability granted which is READ, and it should show the role as "caldera\_forms\_access".

Now add a new Custom Capability to the role called "caldera\_forms\_manage\_options" and make sure GRANT is checked and then save the role.

The saved role should show as "caldera\_forms\_access" and say that it has 2 Granted capabilities.

CODE SNIPPETS PLUGIN

Once Code Snippets is installed and activated, ADD NEW snippet called Caldera Forms Access and copy and paste the following:

```
///////////////////////////////////////////////////////////////////////////////
/*** Grant access to Caldera Forms plugin options/admin page by Jeff Sherk ***/
///////////////////////////////////////////////////////////////////////////////
// CF requires manage_options capability in order to access the options/admin page.
// This code will allow users that do not have manage_options capability to access it.
// (1) From the MEMBERS plugin, go to Add New Role and create a role (should have 1 capability of READ=grant) and call the new role "caldera_forms_access".
// (2) Edit this new role and add a custom capability called "caldera_forms_manage_options" (grant must be checked).
// (3) Assign the role to the user you want to have access.
add_filter( 'caldera_forms_manage_cap', function( $cap, $context ) {
    if ( $cap == "manage_options" && is_user_logged_in() ) { // A request to CF that requires manage_options was made.
        $user = wp_get_current_user();
        $roles = (array)$user->roles;
        if ( in_array("caldera_forms_access", $roles) ) { // Does user have the custom role we created that they need to get access?
            $cap = "caldera_forms_manage_options"; // Change the capability to the custom one we added in the custom role.
        } else {
            // If they do not have the custom role, then do nothing. Users that already have the manage_options capability will still be able to access the plugin as before.
        }
    }
    return $cap;
}, 10, 2 );

```

Make sure to SAVE and ACTIVATE the snippet.

GRANT ACCESS

Now go to any users profile that needs access, under their User Roles section of their profile you can check the Caldera Forms Access box, and save the change, and they should be good to go!

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


title: CiviCRM WordPress uninstall - db issue

text:
# Question
Title: CiviCRM WordPress uninstall - db issue
Uninstall CiviCRM from WordPress, is creating me a big issue.

I needed to uninstall CiviCRM (5.31.1) from a production site, saving all theme and others settings. CiviCRM went away without uninstall its db data. So:

1. I tried to delete the tables using phpmyadmin, failing
2. From command line, I dropped the db and I recreated it from a dump, cutting away the CiviCRM part, maining all tables without `wp_` prefix; doing this the Wordpress site operate all as well.

Some days ago it was necessay to reinstall CiviCRM... All was good until we clicked the plugin enable link, recieving this page:

```
Initialization Error

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

    [code] => -18
    [message] => DB Error: no such table
    [mode] => 16
    [debug_info] => SELECT id, name, value, domain_id, contact_id, is_domain, component_id, created_date, created_id
FROM civicrm_setting
WHERE (domain_id = 1) AND (is_domain = 1)
 [nativecode=1146 ** Table 'sat_wp2020.civicrm_setting' doesn't exist]
    [type] => DB_Error
    [user_info] => SELECT id, name, value, domain_id, contact_id, is_domain, component_id, created_date, created_id
FROM civicrm_setting
WHERE (domain_id = 1) AND (is_domain = 1)
 [nativecode=1146 ** Table 'sat_wp2020.civicrm_setting' doesn't exist]
    [to_string] => [db_error: message="DB Error: no such table" code=-18 mode=callback callback=CRM_Core_Error::simpleHandler prefix="" info="SELECT id, name, value, domain_id, contact_id, is_domain, component_id, created_date, created_id
FROM civicrm_setting
WHERE (domain_id = 1) AND (is_domain = 1)
 [nativecode=1146 ** Table 'sat_wp2020.civicrm_setting' doesn't exist]"]

```

Where old CiviCRM data are still inside db?

Did someone prepare a SQL script performing correct db uninstall?

Could be possibile to add the data delete checkbox during plugin uninstall process, like in many others Wordpress plugins?

TIA -- Francesco

# Answer
It sounds like you still have a civicrm.settings.php file. To uninstall you need to delete that too.
> 2 votes

# Answer
You have to delete the 'civicrm' folder in 'wp-content/uploads' to be able to reinstall the plugin
> 0 votes

---
Tags: wordpress, database, installation, settings
---


# Question
Title: Problem creating Drupal users using Rules and Webform integration
I have a simple Drupal webform that is integrated with Civi and creates a tagged contact. I use the approach described by @petednz at https://civicrm.org/blog/petednz/creating-drupal-users-made-easy-for-single-or-multiple-contacts-via-civi-imports-and to create a Drupal user and log them in when the form is submitted. In my case this then gives them access to a larger form where I want them to be able to save a draft and return later, hence the need for the user account.

Here's the rule that I'm using:

```
{ "rules_friends_tag_account_create" : {
"LABEL" : "Self Create User Account and login",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "CiviCRM", "CiviCRM User" ],
"REQUIRES" : [ "civicrm", "rules" ],
"ON" : { "civicrm_entity_tag_create" : [] },
"IF" : [
  { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ] } },
  { "data_is" : {
      "data" : [ "civicrm-entity-tag:entity-table" ],
      "value" : "civicrm_contact"
    }
  },
  { "data_is" : { "data" : [ "civicrm-entity-tag:tag-id" ], "value" : "6" } }
],
"DO" : [
  { "civicrm_entity_action_create_user" : {
      "USING" : {
        "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ],
        "is_active" : "1",
        "notify" : "1",
        "signin" : "1",
        "username_format" : "first last"
      },
      "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
    }
  },
  { "user_unblock" : { "account" : [ "civicrm-user" ] } },
  { "user_add_role" : { "account" : [ "civicrm-user" ], "roles" : { "value" : { "7" : "7" } } } }
]

```

} }

This has been working reliably for some months, and seems rock solid when I test it.

However I'm seeing behaviour from users that suggests that it isn't working all the time: i.e. sometimes I see that they have submitted the first form two or three times in quick succession, suggesting that they are not reaching the second form, but getting an access denied message instead, which is what would happen if the user account wasn't created for them.

Also, in recent days, I've seen on two or three occasions now the following error message in the Drupal log:

```
Unable to get variable civicrm_user, it is not defined.

```

Why might this rule be working fine for much of the time, but not consistently? How can I debug this? Is there a more robust approach that I could take?

# Answer
I've been using the CMS user extension https://civicrm.org/extensions/cms-users (with Drupal 9 / CiviRules) successfully.
> 1 votes

# Answer
You can register users through Webform Registration module. This module allows maximum flexibility to control the user registration process.
> 0 votes

---
Tags: drupal, drupal-rules
---


title: "Open Case" page customization?

text:
# Question
Title: "Open Case" page customization?
I did some significant customization of CiviCase over a year ago for an agency I work with. It was all through the front end with custom fields and the like, not any programming at the time.

They never got around to using it, but are now starting to. Formerly the custom field sets only showed up on the "Manage Case" page after case creation, and made sense in that context, now they are showing up on the "Open Case" page and everything is in a seemingly nonsensical order, pushing required fields like "Subject" way down the page. The former behaviour was a bare-bones "Open Case" page with no custom fields.

I can't find any way to customize the "Open Case" page either by re-ordering or removing elements. I'd settle for bringing the required Case fields of Subject, status, etc. to the top above my custom field sets. The "Order" field in the field set seems to have no effect on how things are displayed on the "Open Case" page.

Can anyone point me in the right direction? The only thing web searching has turned up for me is a conversation which led to the current sequencing and naming of the default elements.

# Answer
> 2 votes
For rearranging, you can use https://civicrm.org/extensions/rearrange-fields-new-case-form.

For hiding, you can insert some css `display: none` for the fields/rows. See https://docs.civicrm.org/dev/en/latest/framework/resources/#css-stylesheets

---
Tags: civicase
---


# Question
Title: How can I emulate a CiviDiscount when using Webform CiviCRM?
I want the user to be able to type a Discount code into a field and then I want that Discount code (if applied correctly) to result in a reduction of their Membership Fees;

# Answer
This is easy to configure with webform civicrm (a Drupal module) - here are the steps:

**A. Create a native webform field - call it Discount Code.** Let's put it at the top - where we're going to select the Membership Type:

**B. Go to your CiviCRM Tab -\> then to Memberships -\> and hit the checkbox on Membership Fee;** this will expose it to the webform;

**C. String it together with Conditionals:** in your Webform Tab -\> hit Conditionals Here's mine:

**D. Let's test the Form:** here are the three scenarios:

**Select Professional Membership - we don't have a Discount Code:**

**Select Student Membership - we don't have a Discount Code:**

**Select Student Membership - and we have a Discount Code:**
> 13 votes

# Answer
Consider using the suggestion below from KarinG to manage a larger list of Discount codes effectively.
> 1 votes

---
Tags: webform-civicrm, cividiscount, discounts
---


# Question
Title: Error "Database does not support creation of triggers" when installing CiviCRM 5.33.0 on Wordpress 6.2
We are trying to install CiviCRM 5.33.0 (not the latest because of an SQL error that we previously got) on Wordpress 6.2 and keep getting the error "Database does not support creation of triggers". We think that it could be a database access or with the web host issues but not at all convinced about it.

Any help?

Thanks a lot

# Answer
> 0 votes
You'll need to ask your hosting provider if the account supports database triggers. Sometimes it doesn't with shared hosting. See also https://docs.civicrm.org/installation/en/latest/general/requirements/#mysql-configuration

---
Tags: wordpress, error, installation, trigger
---


# Question
Title: How to create a CMS User account for mailprocess
Sorry for the Newbie question, but often the extensive civicrm documentation assumes user knowledge that newbies don't have.

I cannot find out how to create a CMS user.

I am trying to setup email on my drupal 9 CIVIcrm using https://docs.civicrm.org/sysadmin/en/latest/setup/civimail/, which specifies the need for a "user login account ( -u mailprocess )" with "these minimum permissions." "These minimum permissions" is a hyperlink to: https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/. Under the section "Choosing a CMS user" it specifies that it has to have correct permissions. At minimum those are:

* View all contacts
* Access CiviCRM
* Access CiviMail

OK, so I have deduced from this that the term "user login account" is synonymous with "CMS user," but nowhere can I figure out how to add either one. I cannot even figure out whether that is a CIVIcrm "CMS user" or a drupal "CMS user." The best I can do is to add a "contact" but that requires an email address, which makes no sense for a systems user, such as "mailprocess."

I also saw the possibility of adding a "role", aka "user" in some computer languages. But the roles do not allow setting these three permissions.

So, can someone explain how to create the "mailprocess" user and set the above permissions.

Thanks,

Joe

# Answer
> 1 votes
You're right the docs intentionally don't repeat information that really belongs in other software's documentation. But it does assume you know CMS means, in this case, Drupal. Drupal is separate software that has its own documentation. For managing user accounts in drupal, see https://www.drupal.org/docs/user\_guide/en/user-chapter.html

---
Tags: user-account
---


# Question
Title: CiviCRM Membership form Renewal text not displaying
I have a question about the functionality of membership forms for renewals.

We've got our CiviCRM membership form set up with both new membership and renewal text/copy:

As I understand it, it's the same page that changes title/text based on the member status.

I can't for the life of me get this renewal title/copy to appear on our membership page. Does anyone know how this title/text change is triggered? Does it appear because of a membership status eg 'grace'/'expired'? Would it appear with a membership status as 'current' but nearing the end date of the membership?

Thanks for any suggestions!

# Answer
It should appear if the user is logged in or is using a checksum and has a Membership status which can be renewed, eg New, Current, Grace
> 3 votes

# Answer
> I can't for the life of me get this renewal title/copy to appear on our membership page

If a contact has a valid existing membership - the renewal text is shown on the page. This renewal text is not shown if -

* existing membership is in Pending or Cancelled status.
* existing membership is of type = Lifetime.
> 2 votes

# Answer
In our CiviCRM system, the "Renewal" area will show in the form only when the current membership is already expired, while the "Registration"/"New Membership" area will show when the current membership has the status Ongoing.
> 0 votes

---
Tags: wordpress, civimember
---


# Question
Title: Membership is renewed instead of created when filling out form in link
In our installation of CiviCRM we have one-time memberships and recurring memberships. When participants have a one-time membership that will expire soon, they should receive an email with a personalized link where they should be able to create a recurring membership. The link is: `crm.ourinstallation.org/civicrm/contribute/transact?reset=1&id=2&cid={contact.contact_id}&{contact.checksum}` where id=2 refers to the Contribution page number 2. This email is sent one week before the one-time Membership expires, i.e. the one-time Membership will mostly have the status "ongoing" when the form is filled out, but it could also happen that participants will only fill out the form after their membership has expired.

When I fill out this form as a test user, the system does not create a new recurring Membership (while keeping the expired one-time Membership). This would be ok in general, but the values of End Date as well as other fields are not deleted/changed. Which means that the recurring Membership automatically expires at the end date of the previous one-time Membership, which is wrong.

Configuring the Contribution page with ID 2, there are two areas "Registration" and "Renewal". I can set a title and a text for both of them. It seems that when the current membership is already expired, the "Renewal" area will show to the user in the form, while the "Registration" area will show when the current membership has the status Ongoing. **However, no matter if I fill out "Renewal" or "Registration", in both cases no new membership is created (but the status of the old one changed).**

Now, I figured out that when I change the form link to `crm.ourinstallation.org/civicrm/contribute/transact?reset=1&id=2&cid={contact.contact_id}&{contact.checksum}?mid=1`, I can deliberately produce an invalid membership renewal. In this case, I have a warning popping up: `The membership you are trying to renew seems to be invalid. Contact the admin of your website if you need help. If you continue, a new membership will be created.` (translated by me) It was my idea for a workaround to simply use this page and hide the warning per CSS, so participants would always just create new memberships.

**However, also if I continue, no new membership will be created (but the status of the old one changed), even though the warning explicitly says so.**

Is this expected behavior? How can I create a personalized link to create an additional membership of type recurring?

**Edit** @petednz: The system has one membership type ("Test Membership") for one-off, and three membership types (monthly, quarterly, yearly) for recurring.

**Edit2** @PradeepNayak: The membership is indeed renewed when the payment is completed, but the end date is wrong then. For example, I create a one-off membership for 2 months on April 06. It ends on June 06. Then, on June 20, I want to create a recurring membership (monthly payments) via the personalized online form. I pay the first payment and the membership renews until July 06. This is wrong (should be July 20).

Creating a second organisation is not really an option for the long-term, as many more membership types should be implemented in the future. Sth like guitar course, drums course... We would need a new organisation with a new membership type for every single new course. Which seems like a huge overload.

# Answer
If the membership type belong to same organization then Civi will renew the membership i.e push the end date and status when the payment is completed.

If you want multiple membership I would suggest to create second org and have the other membership set to second org.
> 3 votes

---
Tags: civimember, renewals
---


# Question
Title: How do I resolve the error: "The field 'grant_type_id' doesn't exist. in civicrm_api3()" using Drupal 9.x CiviCRM 5.52.3
Error when clicking "CiviCRM" tab when building a new Webform:-

"CiviCRM\_API3\_Exception: The field 'grant\_type\_id' doesn't exist. in civicrm\_api3()"

# Answer
So it turned out to be the CiviGrant extension which is disabled by default.

This used to be a core Component but is now an extension which must be enabled to resolve this error.

To enable the extension, navigate to: "Administer/System Settings/Extensions" and click "Enable" on the "CiviGrant" line.
> 0 votes

---
Tags: webform-civicrm
---


# Question
Title: Warning on confirmation screen for event registration
When the user clicks the "review your registration button" the confirmation screen gives a warning.

> Warning: array\_key\_exists(): The first argument should be either a string or an integer in /home/customer/www/crm.coma.org/public\_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 39

Everything works if they click "continue" but we think this message may be putting off people from registering.

I don't really know when this started, but the only thing I have changed recently is to install Cividiscount. I'm running CiviCRM 5.35.1 on WordPress. The version of Cividiscount that installed was 3.8.2 which should be OK. Disabling Cividiscount doesn't help.

# Answer
> 1 votes
I did a bit more testing and found that the online booking for the event behaved normally if I changed the profile to the standard event one so suspected the new custom fields that I had created for participants. I found that a field with a numeric type and dropdown selection for entry was the cause of the problem. Creating a new custom field with alphanumeric type solved the problem. My dropdown options weren't numeric so maybe that was the problem.

---
Tags: civievent
---


# Question
Title: Nagios script returns 403 error when querying CiviCRM via Ajax API
I've recently started using the check\_civicrm script from https://github.com/MegaphoneJon/check\_civicrm

It works great and my monitoring is greatly improved. However, on some sites I get a 403 error instead of expected response from CiviCRM. I successfully determined that the earlier 500 errors were due to lack of anonymous permission on "CiviCRM: access AJAX API".

Adding to the mystery is the fact that two of the installations are on the same server. One gives expected output, the other a 403. I assume there is some additional permission required somewhere, but I am at a loss to figure out what.

The Civi log is not particularly edifying either, just telling me `Civi\API\Exception\UnauthorizedException: "Authorization failed"`

**UPDATE:** I have dug into the script and see that is is making a POST request to https://sitename.com/civicrm/ajax/api4/System/check. When I visit it in a browser I get a 401 error and the message `"Ajax requests can only be issued by javascript clients, eg. CRM.api4()."`.

Any thoughts?

# Answer
After more digging in response to my Ajax check in a browser I found a question: How can I call api directly from external http?, that didn't answer my question, but referenced the AuthX extension. I thought I would take a look at my sites' extension lists.

The sites that weren't talking to me did not have the AuthX CiviCRM extension installed and the ones that were communicating, did. After installing the AuthX extension, the site would talk to me without any further configuration.

I do not know what underlying services or restrictions are involved, but this provided a path through. Hopefully this is useful to some other searcher (maybe future me).
> 2 votes

---
Tags: api, permissions
---