# Question
Title: can't install civicrm on fresh wordpress
> Warning: Smarty error: problem creating directory 'C:/domains' in C:\domains\xxx.be\subdomeinen\wordpress\wwwroot\wp-content\plugins\civicrm\civicrm\packages\Smarty\Smarty.class.php on line 1094
>
> Warning: include(C:\domains\xxx.be\subdomeinen\wordpress\wwwroot/wp-content/uploads\civicrm\templates\_c\en\_US\\%%E6\E65\E656EDCD%%wordpress.tpl.php): failed to open stream: No such file or directory in C:\domains\xxx.be\subdomeinen\wordpress\wwwroot\wp-content\plugins\civicrm\civicrm\packages\Smarty\Smarty.class.php on line 1264
>
> Warning: include(C:\domains\x.be\subdomeinen\wordpress\wwwroot/wp-content/uploads\civicrm\templates\_c\en\_US\\%%E6\E65\E656EDCD%%wordpress.tpl.php): failed to open stream: No such file or directory in C:\domains\xxx.be\subdomeinen\wordpress\wwwroot\wp-content\plugins\civicrm\civicrm\packages\Smarty\Smarty.class.php on line 1264

can't find sollution; Any ideas?

# Answer
This really looks like you're trying to install on a hosting provider, but you downloaded the WordPress package for Windows. I can see how this might have happened given the WP site, but it's not at all what you wanted.

Which hosting provider are you using? Do they offer WHM/cPanel? Or Plesk? These are management frameworks for hosting providers. Inside them you should find something like Softaculous - this will do the WordPress install for you. Once your domain has the minimal WP in place, you'd do the following.

1. confirm you can reach your VPS using the ssh protocol. You will use ssh for remote management tasks and scp (secure copy) to move files back and forth.
2. Download the Civi zip file.
3. scp (using WinSCP or similar) the file to the default location for user root - that's the manager account.
4. ssh into the system, change to the WP plugins directory, and unpack the Civi zip file. This might vary depending on the system you're on, but here is how we'd do it on the cloud provider I manage:

ssh root@brandnewwpsystem.com
cd ~/wp-content/plugins unzip
/root/civicrm-4.7.19-wordpress.zip
5. Log into WordPress, you should have a Civi tab at the upper left. Depending on the layout you might have to manually configure the MySQL database.

This is a five minute task for someone who's done it a few times. Do not hesitate to ask more questions if you get stuck.
> 1 votes

# Answer
The issue is that your paths use backslashes in some places and forward slashes in others. Windows uses backslashes; Linux and Mac OSX use forward slashes.

Because this is a fresh installation, this is likely to be a bug - similar bugs have crept in from time to time. However, I'm a bit mystified how that could be the case, because the code in question (`<civicrmroot>/packages/Smarty/internals/core.create_dir_structure.php`) concerns itself precisely with the issue of handling slashes correctly. I don't have a Windows machine on which to test the installation, so I'm afraid I can't be of further assistance.
> 0 votes

# Answer
fwiw I am facing a similar issue without the additional backslash question, ie I don't get anything like

> Warning: Smarty error: problem creating directory 'C:/domains'...

Civicrm is showing as active in plugins, but I get warnings and a fatal when trying to get to the Civicrm home page in wordpress. First one is below (...wp-content/uploads/civicrm/templates\_c/en\_US is an empty folder)

> Warning: include(/volume1/web/wordpress/wp-content/uploads/civicrm/templates\_c/en\_US//%%40/40D/40D353E1%%fatal.tpl.php): failed to open stream: No such file or directory in /volume1/web/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php on line 1270

It then lists all the include paths

> (include\_path='.:/volume1/web/wordpress/wp-content/plugins/civicrm/civicrm:/volume1/web/wordpress/wp-content/plugins/civicrm/civicrm/packages:...

followed by a fatal

> Fatal error: Uncaught CRM\_Core\_Exception: \[0: Transaction integrity error: Expected to find active frame thrown in /volume1/web/wordpress/wp-content/plugins/civicrm/civicrm/Civi/Core/Transaction/Manager.php on line 107

Wordpress 4.9.8, Civicrm 5.6.1
> 0 votes

---
Tags: wordpress, install, windows
---


# Question
Title: Using CiviEvent Shopping Cart with Wordpress
Is it possible to navigate to the View Cart page in Wordpress?

# Answer
> 2 votes
It's Ok, it's early. I worked it out.

http://locahost:8080/**civicrm/?page=CiviCRM&q=civicrm/event/view\_cart**

---
Tags: wordpress, civievent
---


# Question
Title: What Drupal modules do I need in order to
I'm working on an electoral project. I'd like to try a little experiment with direct democracy. All involved would be Contacts within CiviCRM.

What Drupal/CiviCRM modules/extensions would I need to accomplish the following:

1. Each candidate would have content (Blog/Forum/Polls) created by them that is viewed only by Contacts within their electoral district. The electoral district relationships are in pre-loaded CiviCRM multi-value custom fields.
2. Each contact (voter) would be able to see and edit (comment/poll vote) the content from #1 for each candidate in a district that the voter resides in. Content from other candidates would be invisible.
3. A contact can be both a candidate and a voter.
4. I've already got ACLs set up which associate a candidate user ID with the voter Contacts in the electoral district. I can, if necessary, create an ACL which associates a voter user ID with all the candidate Contacts in the voter's districts, although that seems very cumbersome.

I'm assuming that all of the candidate/voter interaction will occur within Drupal content.

CiviCRM 5.3.2 Drupal 7.60

# Answer
> What Drupal/CiviCRM modules/extensions would I need to accomplish the following:
>
> Each candidate would have content (Blog/Forum/Polls) created by them that is viewed only by Contacts within their electoral district. The electoral district relationships are in pre-loaded CiviCRM multi-value custom fields.

I would use OG and get some custom synch stuff done so that OGs are populated based on Relationships (we have done this for other clients)

> Each contact (voter) would be able to see and edit (comment/poll vote) the content from #1 for each candidate in a district that the voter resides in. Content from other candidates would be invisible.

Well if we are going down the OG route for #1 then I would stick with that for this too.

> A contact can be both a candidate and a voter.

Not sure what the point/question is here, but would assume Drupal Roles so that within the OG the 'voter' has more options than the 'candidate'. But if you mean they might be a Voter in one district and a candidate in another then again the OG approach would fit.

> I've already got ACLs set up which associate a candidate user ID with the voter Contacts in the electoral district. I can, if necessary, create an ACL which associates a voter user ID with all the candidate Contacts in the voter's districts, although that seems very cumbersome.

It isn't clear how you are doing this since your terminology is jumping between 'user id' and presumably civi relationships, but i would use Fuzion's Permissioned Relationships extension to take care of this, and that knits well with the OG approach

> I'm assuming that all of the candidate/voter interaction will occur within Drupal content.

Right, so am I - using OG in case that hasn't been clear yet ;-)
> 2 votes

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


# Question
Title: How to install civix and build an extension in drupal
Please I don't know how to install civix and build an extension using civicrm. I already installed drupal and civicrm module. but I have no clue how to write an extension or how to run anything here. I am totally new to it.

thanks

# Answer
> 3 votes
Have a look at the Developer Guide here: https://docs.civicrm.org/dev/en/latest/ as a start.

If at all possible I would recommend trying to find an expert near you who would be able to give you a developer training. You would have to pay for it but it will probably save you a lot of exploration time :-)

# Answer
> -1 votes
Download Buildkit from github. Then set environment variable.
Set civicrm.setting.php in evvironment variable (C:\xampp\htdocs\drupal\sites\default\civicrm.setting.php)
Then goto the directory -\> {I am using xampp -\> C:\xampp\htdocs\drupal\sites\default\files\civicrm\ext ).
Open your cmd (right shift + right click) then type
civix civicrm:ping

---
Tags: civicrm.settings.php, civicrm-buildkit, civix
---


# Question
Title: The CiviCRM debug log should not be downloadable - generated .htaccess seems ok
On the `civicrm/a/#/status` the security message *The CiviCRM debug log should not be downloadable* is displayed. And the complaint is correct, I am able to download the log file. But CiviCRM does generate the correct `.htaccess` file in de log directory in the following format

```
<Files "*">
  Order allow,deny
  Deny from all
</Files>

```

The used configuration is CiviCRM 5.3.1, Drupal 7.0 and Apache/2.2.15.

The `.htaccess` file is seen by apache. I tested this by making a syntax error in the file. That is reported by the webserver.

Does someone has a hint to get it working again.

# Answer
> 1 votes
It's possible that the config for the virtual host/Directory does not allow .htaccess override for the Limit directive type, and so is ignoring the Order commands.

See https://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

# Answer
> 1 votes
I found a solution. But thanks @Demerit, you gave the start. I made the assumption that the configuration `.htaccess` is done differently for Apache 2.2. And the drupal `.htaccess` gave some inspiration. I created the following file

```
<Files "*">
  Require all denied
</Files>

```

And that works. Because there is already a .htacess file CiviCRM does not overwrite it.

---
Tags: security, logs
---


# Question
Title: CiviMail: What is the expected behaviour when unsubscribing from a mailing sent to a parent group?
I'm sure I remember reading somewhere ages ago that when unsubscribing from a mailing sent to a parent group, the contact would be removed from all of the child groups that they belong to that are under that parent group.

Has anyone got a reference for this expected behaviour when this functionality was put together/documented?

My personal view is that it would be better if they were only removed from the parent group. Being removed from the child group would seem to break any hierarchical group mailing system that an organisation has setup.

Note, this is a follow up to the issue https://issues.civicrm.org/jira/browse/CRM-19924 "Unsubscribe from a mailing sent to a parent group silently fails" i.e. currently nothing happens at all when a user clicks an unsubscribe link sent to a parent group.

# Answer
We abandon this method of manage mailing lists and turn on adding members to mailing groups as "expected" (not with parent or with smart groups). GDPR regulations pushed us to get this direction and avoid the problems described in your question at the same time.

Maybe we should complete the documentation to advise against the use of parent groups as a mailing groups, as long as it is possible to do so.
> 1 votes

---
Tags: civimail, groups, smartgroups, unsubscribe
---


title: NEWBIE - Move Data fields in input form

text:
# Question
Title: NEWBIE - Move Data fields in input form
Members, as a relative newbie to Civi, i would like move some entry forms for a new contact (in germany, zip comes before city...) basically it is relevant to adresses now, but there could be more fields. I know i could create a custom profile for that, but could you give me a hint where to look for the code? i cannot find the tpl-file....

System: wordpress 4.9.8, civi 5.6.0

i hope my question is understandable ;-).

Thanks very much in advance,

Walter

# Answer
there is a section in the Developer Guide on templates: https://docs.civicrm.org/dev/en/latest/framework/templates/

This includes some pointers on how to customize templates. Having said so, you might also be tempted to put this in an extension as you might run into some more "Germanization":-) Are you aware of the German CiviCRM mailing list?
> 2 votes

---
Tags: wordpress, forms
---


title: Wrong time in Mailing Report

text:
# Question
Title: Wrong time in Mailing Report
as said in the title, the mailing report seems to have a wrong time...when I send a mailing to my private email adress at 4 pm and open it right away, the mailing report says I opened it 2 hours ago. Not much of a big problem here but it triggers me anyway!

Would be very thankful for some help!!

Ben

# Answer
Glad to have been able to help - reposting my comment as a response and kindly requesting that you mark it as accepted given your findings.

> When you've got things running on different servers, there is a chance that dates and times may be mismatched - e.g. your mail server might be configured with a time zone that is different from the server on which your civi instance is installed and hence the time is incorrectly translated. Determining whether this is the case would be the first step.

Glad I could be of help!
> 1 votes

---
Tags: civireport, mailing
---


title: CiviMail Mailing Scheduled But Not Sent

text:
# Question
Title: CiviMail Mailing Scheduled But Not Sent
I have set up a mailing and scheduled it. The date and time has been and gone and the status is still scheduled... Any ideas where I am going wrong?

# Answer
It's possible that your cron isn't set up. I would check to make sure that your Status Console (**Administer menu » Administration Console » System Status**) doesn't have a "Cron Not Running" message (check the hidden statuses if there are any!).

It's also possible that the Scheduled Job to send mailings hasn't been enabled. Check **Administer menu » System Settings » Scheduled Jobs** and ensure that *Send Scheduled Mailings* is enabled. You can also see the last time it ran and ensure it matches your expectation from cron.

Finally, if the job DID run, click the **View Job Log** link next to the *Send Scheduled Jobs* record. If you're not sure how to interpret the result, please edit your original question to include the log.
> 3 votes

---
Tags: civimail, email
---


title: Unwritable Extensions Directory

text:
# Question
Title: Unwritable Extensions Directory
When I go to the Admin \> Extensions \> Add New, I get the following error...

"Directory Unwritable Your extensions directory is not set or is not writable. Click here to set the extensions directory."

When click on the link, it takes me to the Settings - Upload Directories page, but it is totally blank.

Any clues please?

# Answer
I guess you dont have write permission on Extension folder

What you need to do is try to find if you have Extension folder already

Administer -\> system setting -\> Directories - look for **CiviCRM Extensions Directory**

you should find a path in Civicrm 4.7.x ext folder will be created against the below location -

.../sites/default/files/civicrm/ext

If folder exist then try to navicate to the location in Command prompt or Winscp and provide write permission to the folder - this should fix the issue

refer to the below link - additional reading

Are there recommended directory ownership and permission settings for CiviCRM files?

https://forum.civicrm.org/index.php?topic=10545.0

I guess this helps!!!
> 2 votes

# Answer
This problem began for me after the 5.4.0 and my upgrade to 5.6.1 didn't help.

I added the override for the extensions directory in the civicrm.settings.php (found in /home/xxxxxx/public\_html/wp-content/uploads/civicrm).

// Override the extensions directory. $civicrm\_setting\['Directory Preferences'\]\['extensionsDir'\] = '/home/xxxxxx/public\_html/wp-content/uploads/civicrm/ext';

and now I can see the extensions, install and upgrade within CiviCRM.
> 2 votes

---
Tags: extension, filesystem
---


# Question
Title: Getting an error trying to add contacts to a group from an activity report.
Getting this error when trying to add contacts to a group from a report.

Table 'childpsy\_civicrm.Array' doesn't exist

It's this 'xxx\_civicrm.Array' doesn't exist that puzzles me. I'm getting it on another site, but not on others. The CiviCRM Demo site works fine. But that's 5.8.1

Also when viewing a contact, to see what groups they are in....the smart group membership does not work. Using v 5.6.

Can anyone repeat this?

# Answer
> 2 votes
OK my bad. Upgraded to 5.6.1 and problems disappear.

---
Tags: civireport, error
---


# Question
Title: Mailchimp Integration pushing but not pulling
I have the "Mailchimp & CiviCRM" integration (v2.0) installed, and have created a Smart Group containing current mailable members which I've linked with a test MailChimp group. I've activated the Push job, but not the Pull job, as from what I understand I want CiviCRM to be the source of truth and push to MailChimp. The push seems to work, but the description of the module here: https://vedaconsulting.co.uk/civicrm-mailchimp seems to indicate that it will also pull back to CiviCRM when a user or admin unsubscribes.

This has not been the case in my testing -- when I unsubscribe my own user through the admin screen on MC, the Smart Group never gets updated. On the next scheduled push, the user shows up in MC as Subscribed again. I've double checked the Webhook settings, and they are set as shown in the above link. What am I doing wrong -- am I misunderstanding the push/pull, and I need to activate both jobs? Will this work correctly, so that individual unsubscribes are pulled from MC immediately, but everything else comes from Civi?

# Answer
To clarify, the following activity on MailChimp is communicated immediately (within several seconds) via WebHook (this does not happen during the push sync):

* Any users that unsubscribe themselves in MailChimp will have the Do not email flag set in their CiviCRM Communication Preferences
* If a contact is removed from a group in MailChimp, then the contact is also removed from the corresponding group in CiviCRM
* A new contact who subscribes directly via MailChimp will be added to CiviCRM as a contact within the corresponding mailing list group(s) that they subscribed to
* Changes to contact names in MailChimp will be updated in the corresponding contact record in CiviCRM

If you have completed webhook the steps listed in the documentation, make sure you resubscribe yourself directly on MailChimp first, then:

1. Verify whether the "**Mailchimp: Allow Webhook Posts**" permission has been toggled for the Anonymous User role:

> 1. Navigate to Administer \> Users and Permissions \> Permissions (Access Control)
> 2. Click on the "\[CMS Name\] Access Control" hyperlink (e.g. "Drupal Access Control")
> 3. Use CTRL+F to find "Webhook" \> toggle the permission for the Anonymous user role if it is not toggled
> 4. Click the Save button

1. **Confirm MailChimp Group Settings**:
> 1. If using the Membership Sync, toggle the option to "**Ensure list's webhook settings are correct at MailChimp when saved**"
>     2. If using the Interest Sync, toggle the option of "**Subscribers are able to update this grouping using MailChimp**"

If you made any changes to the above settings, test again by removing yourself from a group and/or unsubscribe yourself directly from MailChimp, then navigate to your contact record in CiviCRM (or refresh after a couple of seconds if you are already there):

1. If you removed yourself from a group, then click on your Groups tab to see that you were removed by API from the corresponding group in Civi
2. If you unsubscribed yourself entirely, then the DO NOT EMAIL flag should be toggled on your contact record

Hope this helps!
> 2 votes

---
Tags: mailchimp
---


title: Completely lost. Help!

text:
# Question
Title: Completely lost. Help!
No one at our organization knows how to use Civi. The person who set it up is no longer on staff. How do we even get in touch with someone? We urgently need to get into our account on the Civi website and have no idea how to update the login credentials. Please help!

# Answer
CiviCRM is open source software so there isn't so much a 'company' to go to for help as a 'community'. Within that community there are Partners who can provide professional support but they and many other users also provide a lot of free help through StackExchange (SE) and via chat.civicrm.org.

If it would help, we could have a quick skype call (~20 mins) just to help sort out some basics from you, and then via SE etc help you with your more specific issues.

You can ping me via peter.davis59 on skype if you have it, or I can supply an email if you do not.

Otherwise, to help you find what CMS you have (which may help folk help you) you could try to go to your /user or /wp-admin - the former would confirm it was Drupal CMS (the website that sits in front of CiviCRM), the latter would be WordPress. Or your site might be Joomla.

Going to eg /user would then help you 'request a new password' if there is already an account that was set up (hopefully you can access the email of the person who is no longer on staff). With that new login you should then be able to access the CMS and through that, find a link to CiviCRM for your site.
> 4 votes

---
Tags: database
---


# Question
Title: Can Wordpress handle multi-site CiviCRM the same way Drupal 7 with domain access does?
My organization is currently running a multi-site CiviCRM deployment on Drupal 7 using the domain access module.

We set permissions on the contacts by using the state field so that the leadership in a state can only see that state's contacts.

Some states also have home pages with custom content and menus, but use the bulk of the national web site as "background" content.

The above configuration has served us well for several years now, but we keep getting push back from states that Drupal is too hard to use and people aren't posting content for that reason.

Can we replicate this same functionality on the WordPress platform? If not, how close can we get?

# Answer
Yes - this can be done - you will find instructions on how to integrate Civi with a WordPress Multisite installation **HERE**.

Hope this helps!
> 2 votes

---
Tags: wordpress, multisite, drupal-multi-site
---


# Question
Title: Error on contribution details display, recently updated system
Current CiviCRM is 5.6.1 running on Drupal 7.60. This system was very recently updated from 4.4.4 running on Drupal 7.36 or something. The updates were done cyclically, one right after the other, to bring it all up to date, and nothing seemed to have gone wrong.

Problem I'm having is when viewing Contact Contributions tab. The main list displays fine, but if I click on the Amount, to get an expanded details view, the expanded area *often* says `Sorry but we are not able to provide this at the moment`, and there is at the same time a pop-up notification bubble that says `One of parameters (value: ) is not of the type Integer`. This does not happen for every contribution, just for many or most of them. Some of them display correctly.

I checked the Troubleshooting help page, which suggests turning on debugging including backtraces, so I did that. Sadly, nothing at all seems to have been added to the log file after reproducing errors with this setup (I don't have shell access to the server, but log files exist and I can ftp them down).

However one interesting thing did happen when I turned on debugging. Now the error message changes. The expanded space in the list is now empty, and the notification bubble says `Network Error Unable to reach the server. Please refresh this page in your browser and try again`. I tried flipping the debug setting on and off a couple times and this was replicable (i.e., with debugging off, the original message about `not of type Integer` came back).

I suppose I should mention, because you never know, that after the upgrades, I get a yellow warning in the System Status saying `the following Price Set Fields use disabled or invalid financial types and need to be fixed if they are to still be used` It refers to a field called `Contribution Amount` that has a type of `Text / Numeric Quantity`, but none of our users know what this field is, whether it is custom added here, or whether it is being actively used. It is not at all clear to me if this could be related to my main problem.

Any clues about how I can debug this are much appreciated, esp. given the situation that nothing seems to end up in the log even with full debugging traces turned on.

# Answer
> 2 votes
I think it would be worth following the lead about disabled or invalid financial types. At /civicrm/admin/financial/financialType?reset=1 , do any of the financial types show as disabled? If so, you could try enabling and seeing if that resolves the error.

If you have SQL access, you could check the financial type of working vs non-working contributions and see if there's a pattern. This is in table `civicrm_contribution`, field `financial_type_id` for the contribution itself and table `civicrm_line_item`, field `financial_type_id` for the contribution's line items.

The way price sets come into it: suppose a contribution page has a price set called Subscription, with price field Journal, with price field values (options) Print and Electronic. When you set up those price field values, you specify a financial type for each. This is stored in table `civicrm_price_field_value`, field `financial_type_id`. If the user selects "Print" and this has a financial type of "Publications", say, then the contribution will include a line item for that subscription, with financial type "Publications".

If the "Publications" financial type subsequently gets disabled or deleted, that could cause issues.

If you have SQL access, this query could shed some light on the message you received during upgrade:

`select pfv.id, pfv.price_field_id, pfv.financial_type_id, ft.name, ft.is_active
from civicrm_price_field_value pfv
left outer join civicrm_financial_type ft on pfv.financial_type_id = ft.id
where pfv.label = 'Contribution Amount'
and pfv.is_active = 1;`

Any results where the last two columns are NULL (indicating a missing financial type) or the last column is 0 (indicating a disabled financial type) could have caused the warning you saw.

Some price sets are used behind the scenes, which could account for "Contribution Amount" not being recognised as a field that users have set up.

---
Tags: contribution-page, price-sets, debugging
---


# Question
Title: Activity Processor issue with Caldera Forms
Using Wp 4.9.8 Caldera 1.74 Caldera Forms CiviCRM 0.4.4

I'm struggling to work out how to expose the activity fields (core and custom) to the layout area once I've added an Activity processor to the form.

I'm using the template for creating two contacts with a relationship, but I need to collect some info and kick off an activity as well, so how do I add the extra fields?

# Answer
> 1 votes
Ok, I worked this one out. You have to create the fields in the Caldera form first and then match CiviFields in the processor you've added to the Caldera fields you've created, it's a bit like mapping fields for import

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


# Question
Title: What is the Membership type 'domain' in the api?
The API explorer shows something promising:

Apparently, each membership type can be connected to a 'domain' which is a contact ?

What exactly is it, and how could I assign these domains to a membership type ? The backend interface does not seem to mention it.

\[EDIT\] anything to do with https://docs.civicrm.org/sysadmin/en/latest/install/multi-site/ ?

# Answer
> 3 votes
On multisite you tie each membership type to a domain id. You can find what the domain ID's by looking at the civicrm\_domain id table (or in the civicrm.setting.php file).

If you create the memberships on the correct domain they will be correct I believe, but if you don't then just adjust the domain\_id in the civicrm\_membership\_type table.

Then only the memberships tied to a certain domain will be available for selection on a given domain.

---
Tags: civimember, api, sub-types, domain
---


# Question
Title: Setting up rule to link CiviCRM contact with Drupal 7 account
I’m using civicrm 4.7.14 with drupal 7.53.

I have a question about these directions: https://wiki.civicrm.org/confluence/display/CRMDOC/Creating+a+Drupal+user+for+every+CiviCRM+contact

When I create the rule, I don't see these options listed as a condition or action:

> CONDITION
>
> NOT Drupal User Account exists for Contact
>
> ACTION
>
> Create Linked Drupal User Account

What am I missing?

Also, what exactly happens here? I understand that new Drupal accounts will be made for the CiviCRM contacts, but will it generate usernames? Will it email everyone on the list automatically? (I don't want to send emails yet.)

# Answer
> 5 votes
First, make sure you have Drupal Rules module and CiviCRM Entity module installed and enabled.

Next, you must name your rule and select an event first and click save, then the condition and action options will be opened up to you.

When you get to the action part, you will see options for how to assign the username (such as "use email address" or "first name.last name", etc. and you can chose if the contact is emailed or not. If you chose for the contact to be emailed, they will be emailed a one-time link to log in and set a password.

Alternatively, you can import the rule instead, using this code:

Go to **Administration » Configuration » Workflow » Rules** and click "**\+ Import Rule**". Then, paste the following code in and click import:

```
{ "rules_create_drupal_account_from_civicrm_contact" : {
    "LABEL" : "Create Drupal Account from CiviCRM contact",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "civicrm" ],
    "ON" : { "civicrm_contact_edit" : [], "civicrm_contact_create" : [] },
    "IF" : [
      { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm_contact" ] } }
    ],
    "DO" : [
      { "civicrm_entity_action_create_user" : {
          "USING" : {
            "civicrm_contact" : [ "civicrm_contact" ],
            "is_active" : "1",
            "notify" : "1",
            "signin" : "0",
            "username_format" : "email"
          },
          "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
        }
      }
    ]
  }
}

```

Note: this code will do the following: Upon updating a contact record in the CiviCRM, it will check to see if the user has a Drupal account and if not, it will make one using the contacts email address. Then it will email them a one-time link to set their password. You can use this code and then edit the rule to tweak the activity.

# Answer
> 2 votes
I realize the request was specifically about CiviCRM *contacts*, but I also wanted to share a similar Rule *specifically* for memberships *(to ensure a Drupal account is created)* for those searching.

Here's the rule for folks looking for that:

```
{ "rules_civicrm_create_drupal_user_on_new_membership_" : {
  "LABEL" : "CiviCRM: Create Drupal User (on new membership)",
  "PLUGIN" : "reaction rule",
  "OWNER" : "rules",
  "TAGS" : [ "CALACS" ],
  "REQUIRES" : [ "civicrm", "rules" ],
  "ON" : { "civicrm_membership_create" : [], "civicrm_membership_edit" : [] },
  "IF" : [
    { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm-membership:contact-id-contact" ] } }
  ],
  "DO" : [
    { "entity_fetch" : {
      "USING" : { "type" : "civicrm_contact", "id" : [ "civicrm-membership:contact-id" ] },
      "PROVIDE" : { "entity_fetched" : { "contact_fetched" : "Contact for Membership" } }
        }
      },
      { "civicrm_entity_action_create_user" : {
        "USING" : {
            "civicrm_contact" : [ "contact-fetched" ],
            "is_active" : "1",
            "notify" : "1",
            "signin" : "0",
            "username_format" : "email"
          },
          "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
        }
      }
    ]
  }
}

```

---
Tags: drupal, user-account
---


# Question
Title: Receipt template formatting (still) broken?
We've upgraded civicrm multiple times the last few years. At a certain point, the receipt templates broke. It stopped showing credit card information and membership start/end date (for membership receipts) became blank.

I've just reverted 'back' to the default templates, assuming that default is the same as the most recent version of civicrm (so, not the 4.5 default we started with, but the 4.7 default we are at right now). But these fields are still broken.

So perhaps these are not the most recent templates. Are there more recent templates I can download somewhere ?

Particularly, I see

```
<td {$valueStyle}>
{$mem_start_date}
</td>

```

Shouldn't that be

```
<td {$valueStyle}>
{$mem_start_date|crmDate}
</td>

```

Or even

```
<td {$valueStyle}>
{$mem_start_date|truncate:10:''|crmDate}
</td>

```

and

```
 {$credit_card_type}<br />
 {$credit_card_number}

```

prints nothing but blanks, as does

```
 {$credit_card_exp_date|truncate:7:''|crmDate}

```

# Answer
You should be able to find the current template files in the repository (https://github.com/civicrm/civicrm-core). It's not clear whether you're on 5.x or in fact still on 4.7 but previous versions should be available as well for you to pull from.
> 1 votes

---
Tags: civimember, 4.7, message-templates, receipts
---


# Question
Title: Blocking Double Click on Form Submit Button
I have a pop-up that loads a form. Currently the user can double click the submit button on the form which results in multiple submissions. This can cause some serious issues depending on the purpose of the form.

Any suggestions on the best way to block double click of submit buttons on forms loaded within pop-ups?

# Answer
> 3 votes
I was able to disable double submission of the form by adding the following to the bottom of the form's TPL file:

```
{literal}
  <script type="text/javascript">
    // PREVENT DOUBLE SUBMISSION OF FORM
    CRM.$(function ($) {
      $(document).ready(function () {
        $('form').preventDoubleSubmission();  //block double submission of form
      });

      // jQuery plugin to prevent double submission of forms
      $.fn.preventDoubleSubmission = function () {
        CRM.$(this).on('submit', function (e) {
          var $form = $(this);

          if ($form.data('submitted') === true) {
            // Previously submitted - don't submit again
            console.log("Form Previously submitted - don't submit again");
            e.preventDefault();
          } else {
            // Mark it so that the next submit can be ignored
            console.log("Form NOT Previously submitted");
            $form.data('submitted', true);
          }
        });

        // Keep chainability
        return this;
      };
    });
  </script>
{/literal}

```

---
Tags: extension, quickform
---


title: CiviCRM on multiple sites

text:
# Question
Title: CiviCRM on multiple sites
Ok, so I gave up on having it in two different locations since I couldn't seem to get a clear answer from anyone regarding it being able to be done. So I've moved everything over and set it up as a Drupal multi-site. Now I am working to connect CiviCRM to the second site. It's already been on the main site for years.

However, the instructions on how to do the CiviCRM multi-site seem to be missing some steps or making some assumptions. As such, I'm stuck. I'm using the instructions here: https://docs.civicrm.org/sysadmin/en/latest/install/multi-site/

The page says:

```
Create the domain record¶
Insert a new domain record into the CiviCRM database. For example if your new contact is 555

INSERT INTO `civicrm_domain` (
  `name`,
  `description`,
  `version`,
  contact_id)
SELECT
  'site 2',
  'second test site',
  cd.version,
  555
FROM civicrm_domain cd
WHERE cd.id = 1;

```

"For example if your new contact is 555" - what new contact? I can add the line, but have no idea what the "contact\_id" field should contain.

As such, I'm stuck at this step.

---

OLD QUESTION:

I know you can have multiple sites using the same CiviCRM install. Usually they are set up using a Drupal multi-site. But can you do it if the two sites are installed in two different locations on the same server? So not a multi-site setup?

I'd love to keep the two sites separate, as then the backups of them are smaller, easier to restore when necessary, etc. Not to mention that I don't bother the live site trying to merge the two (one is a renovation on an older site). If I have to have them in the same directory, I can do that, but would rather not. So I thought I would check.

I want the two sites to be able to have a user be attached to their membership record, for instance, because that controls their access to various items. Or be able to see the trainings they've gone to. Be able to update their record.

So I need to know:

1. Can I have two sites in different directories that use the same CiviCRM install *and* database so that the data is shared? So that the same user can see their same information in Civi regardless of which site they are on?
2. If not, if they are set up as a Drupal multi-site in the same directory, would it work? Would they share the same CiviCRM install *and* database so that the data is shared? So that the same user can see their same information in Civi regardless of which site they are on?

I need to know pretty quickly, because I'm to the merging stage of these two sites and I need to know if I am going to have to completely redo the strategy and do the fake multi-site thing in Drupal where they look to be separate sites, but aren't. I'd rather not do that, though, as it will make our SQL database *huge* since it's an informational site with tens of thousands of records.

# Answer
> can you do it if the two sites are installed in two different locations on the same server? So not a multi-site setup?

Yes multisite can work with different drupal codebase/databases
> 1 votes

# Answer
To answer the followup question - two separate CMSes on the same server can share the same CiviCRM EXCEPT for the users. Since users are controlled by the CMS, the users are tied to the CMS.

If you want to share users, you'll need to use a solution that shares users at the CMS level, like OAuth, LDAP, SAML or Bakery. Or you could just make the same users on both servers. The only catch is that each user will have two CiviCRM records, one per account.
> 0 votes

# Answer
Answering your new question. You say:

> "For example if your new contact is 555" - what new contact? I can add the line, but have no idea what the "contact\_id" field should contain.

In the documentation, in the line above that query it says

> Create a new contact to be the domain contact for the new domain

In other words, every 'domain' needs to have an Organisational contact record that it is associated with.

Does that help?
> 0 votes

---
Tags: drupal, multisite
---


# Question
Title: Current Employer style field for a custom field
I have been asked to add some custom fields to the default CiviCRM Interface that bahave like the current employer field.

That is to say, my users want to create certain relationships and have them turn up in the relationships tab.

I had originally implemented this as a contact reference with a filter to look up the specific sub-set of contacts needed but I have been asked to make them relationships.

I realise I can implement this using webforms integration (we are using Drupal 7) but I have been specifically asked to implement this on the default UI.

I have also read it can be achieved using hook\_civicrm\_post however, I was hoping there was a more straightforward way that I was overlooking so that if in the future one of my users needs to add a new relationship custom field they don't need to update code in an extension

# Answer
> 2 votes
You might have already checked field like "Current Employer" that creates new organization and relationship. Post hook is the most straight-forward and correct way to proceed here.

You could give a common prefix kind of name to your custom field and write your code in such a way that it performs the action only when custom field has that prefix in the title/name. This way, you won't need to modify the extension every time a new custom field is added.

# Answer
> 1 votes
@jitendra's answer is how we will likely proceed to some extent however we will likely integrate it with something like Relationship block which seems to do a lot of what are users want.

---
Tags: custom-fields, relationships
---


# Question
Title: Contact Import Longitude missing in mapping
I am trying to import contacts from one CIVI database to another however when doing the field mapping there is a map for latitude but not one for longitude. Am I missing something, if not is there any way to fix this?

# Answer
See here: Can't find 'longitude' in import wizard

It should be available by default, so yes, open an issue to fix.
> 1 votes

---
Tags: wordpress, import, field-mapping
---


title: Multisite warning Undefined variable

text:
# Question
Title: Multisite warning Undefined variable
After the update 5.6.1, for a user role with non-admin permission, I noticed a warning concerning Multisite that indicate an Undefined variable :

```
Notice: Undefined variable: type in multisite_civicrm_selectWhereClause() (line 229 of /var/data/sites/reveal/public_html/sites/default/files/civicrm/ext/org.civicrm.multisite/multisite.php).

```

This might be linked : any request for let's say the list of contact in a group gives a 500 *Internal Server Error*. The *Recent log messages* always indicate the Undefined variable Notice.

As a non admin and to fully benefit of the Multisite setting, the permission for this role doesn't include **view and edit all contacts**. How can I dig in this ?

# Answer
> 2 votes
==\> I found the trouble : that was in the role setting : Multisite: view/edit/list all contacts in domain was not selected for this role… I my case, all the site share same user and roles along the sites. But the actual setting needs to be defined in each site. Therefore the warning was indeed accurate and indicating a wrong setting for the role.

---
Tags: multisite
---


title: A way to test schedule reminders

text:
# Question
Title: A way to test schedule reminders
I'm looking for a way to test schedule reminders for memberships. We have memberships that expire in a year, and we have setup a renewal reminder which also reminds our back office staff a month before the expiry date. But I need a way to test that the reminder actually works. Is there a way to test this quickly test this...obviously I cannot wait until one month before a particular membership expires to confirm this.

# Answer
> 7 votes
It might help to differentiate types of testing, e.g.

* (*User-oriented*) Click-to-test/in-app test - This is the type of test supported in the CiviMail UI (which sends an example mailing). As dlobo points out, this type of test was not originally part of the scheduled reminder system, but it would be a great addition.
* (*Developer-oriented*) Unit testing - For developers who work on the code, there's a series of automated tests in ActionScheduleTest which simulate a dozen configurations/schedules.
* (*Sysadmin-oriented*) Adhoc testing - At the low-end, one might simply create a fake membership record and set the expiration date to today. At the high-end, one might replicate a site in an isolated environment (eg a local virtual machine), redirect email to disk (CIVICRM\_MAIL\_LOG), and manipulate the clock in the virtual machine. (This may require a deep understanding of the system as well as a lot of time/patience/discipline.)

# Answer
> 7 votes
Only way I know to test it to create an equivalent flow such as

* Set up a new Membership Type - give a contact a membership of that type
* Set up a Scheduled Reminder for above Membership Type
* Set the Membership End Dates so that the Reminder would be scheduled for today
* Run the Scheduled Reminders scheduled job
* To clear and rerun find the entry created by above in the civicrm\_action\_log, remove that row, rerun cron.

Not pretty but it can help. Hopefully if i missed out any steps you are able to make the mental jumps required ;-)

# Answer
> 5 votes
Unfortunately I don't think testing was built into the scheduled reminder functionality. Seems like that aspect was just skipped.

I do think like contribution and event page registrations, having the ability to:

a. test the functionality and email deliverability of scheduled reminders, sending the emails to staff / tester rather than actual person

b. Figure out how to best approach / deal with the time centric nature of scheduled reminders (i.e. how can we test 1 month out reminders? maybe compress time and/or do a scale conversion of time for testing, (i.e. hours become seconds, days becomes minutes, months become hours)

Definitely a medium sized development project and most of the ideas can be tested out via an extension, but this does seem like core functionality sometime in the future.

# Answer
> 1 votes
This isn't perfect since it wouldn't have access to all the same tokens, but as a quick test to make sure there was nothing glaringly awful about the email itself, I just copy/pasted my membership renewal email content into a new generic mailing and sent myself a test that way.

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


# Question
Title: Does Contact Editor Extension work with Version 5.6.1?
I just upgraded to version 5.6.1 from 5.3.1. I tried using the contact editor extension to change a contact type but when I select "Change Contact Type" it take me to the CiviCRM homepage. I use CiviCRM with WordPress.

Does the Contact Editor extension work with 5.6.1?

# Answer
> 2 votes
This happens when the menu link is not registered properly for all extensions. I always have a habit of performing cleanup cache and some times delete template\_c and rebuild menu.

In your case as @Tony said after performing cleanup cache the menu should be registered and the extension should work. You can do this by navigating to CiviCRM \>\> Administer \>\> System Settings \>\> Cleanup Caches and Update Paths \>\> Cleanup caches.

---
Tags: contacts, extension
---


# Question
Title: Upgrade script (5.0.1 to 5.4.1) / DB Syntax error - UPDATE civicrm_msg_template SET msg_text
Context : Wordpress 4.9.8–fr\_FR, PHP version 7.0.22, libmysql - mysqlnd 5.0

Hello When trying to run the upgrade script from 5.0.1 to 5.4.1, I got this issue :

```
    Aug 31 13:51:25  [info] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] =>
        UPDATE civicrm_msg_template SET msg_text = '{assign var=\"greeting\" value=\"{contact.email_greeting}\"}{if $greeting}{$greeting},{/if}\n{if $receipt_text}\n{$receipt_text}\n{/if}\n{if $is_pay_later}\n\n===========================================================\n{$pay_later_receipt}\n===========================================================\n{else}\n\n{ts}Please print this receipt for your records.{/ts}\n{/if}\n\n{if $membership_assign && !$useForMember}\n===========================================================\n{ts}Membership Information{/ts}\n\n===========================================================\n{ts}Membership Type{/ts}: {$membership_name}\n{if $mem_start_date}{ts}Membership Start Date{/ts}: {$mem_start_date|crmDate}\n{/if}\n{if $mem_end_date}{ts}Membership End Date{/ts}: {$mem_end_date|crmDate}\n{/if}\n\n{/if}\n{if $amount}\n===========================================================\n{ts}Membership Fee{/ts}\n\n===========================================================\n{if !$useForMember && $membership_amount && $is_quick_config}\n{ts 1=$membership_name}%1 Membership{/ts}: {$membership_amount|crmMoney}\n{if $amount && !$is_separate_payment }\n{ts}Contribution Amount{/ts}: {$amount|crmMoney}\n-------------------------------------------\n{ts}Total{/ts}: {$amount+$membership_amount|crmMoney}\n{/if}\n{elseif !$useForMember && $lineItem and $priceSetID & !$is_quick_config}\n{foreach from=$lineItem item=value key=priceset}\n---------------------------------------------------------\n{capture assign=ts_item}{ts}Item{/ts}{/capture}\n{capture assign=ts_qty}{ts}Qty{/ts}{/capture}\n{capture assign=ts_each}{ts}Each{/ts}{/capture}\n{capture assign=ts_total}{ts}Total{/ts}{/capture}\n{$ts_item|string_format:\"%-30s\"} {$ts_qty|string_format:\"%5s\"} {$ts_each|string_format:\"%10s\"} {$ts_total|string_format:\"%10s\"}\n----------------------------------------------------------\n{foreach from=$value item=line}\n{$line.description|truncate:30:\"...\"|string_format:\"%-30s\"} {$line.qty|string_format:\"%5s\"} ... \n{/foreach}\n{/if}\n' WHERE id IN () [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1]"]
)

Aug 31 13:51:25  [info] $backTrace = #0 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(232): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(921): CRM_Core_Error::handle(Object(DB_Error))
#2 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: syntax error", -2, 16, (Array:2), "\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...")
#3 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-2, 16, (Array:2), "\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...")
#4 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -2, 16, (Array:2), "\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...", "DB_Error", TRUE)
#5 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1907): PEAR->__call("raiseError", (Array:7))
#6 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-2, NULL, NULL, "\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...", "1064 ** You have an error in your SQL syntax; check the manual that correspon...")
#7 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#8 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...")
#9 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2415): DB_common->query("\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...")
#10 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1607): DB_DataObject->_query("\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...")
#11 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(438): DB_DataObject->query("\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...")
#12 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(1394): CRM_Core_DAO->query("\n        UPDATE civicrm_msg_template SET msg_text = '{assign var=\\"greeting...", TRUE)
#13 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Incremental/MessageTemplates.php(149): CRM_Core_DAO::executeQuery("\n        UPDATE civicrm_msg_template SET msg_text = %1 WHERE id IN ()", (Array:1))
#14 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Incremental/General.php(143): CRM_Upgrade_Incremental_MessageTemplates->updateTemplates()
#15 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Form.php(772): CRM_Upgrade_Incremental_General::updateMessageTemplate("<br />Les exemplaires par défaut des modèles de message répertoriés ci-dessou...", "5.4.alpha1")
#16 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Page/Upgrade.php(111): CRM_Upgrade_Form->setPreUpgradeMessage("<br />Les exemplaires par défaut des modèles de message répertoriés ci-dessou...", "5.0.1", "5.4.1")
#17 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Upgrade/Page/Upgrade.php(73): CRM_Upgrade_Page_Upgrade->runIntro()
#18 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(309): CRM_Upgrade_Page_Upgrade->run((Array:2), NULL)
#19 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#20 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:2))
#21 /var/www/html/civicrm/wp-content/plugins/civicrm/civicrm.php(1246): CRM_Core_Invoke::invoke((Array:2))
#22 /var/www/html/civicrm/wp-includes/class-wp-hook.php(286): CiviCRM_For_WordPress->invoke("")
#23 /var/www/html/civicrm/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters("", (Array:1))
#24 /var/www/html/civicrm/wp-includes/plugin.php(453): WP_Hook->do_action((Array:1))
#25 /var/www/html/civicrm/wp-admin/admin.php(224): do_action("toplevel_page_CiviCRM")
#26 {main}

```

I really don't know how to move forward and run the upgrade script. Any help will be kindly accepted Thanks

# Answer
> 2 votes
This seems to be fixed in 5.6.0. If you have to upgrade to 5.5.1 or have problems so need to do it incrementally, at the suggestion of Aidan@Squiffle commenting out the `UPDATE civicrm_msg_template SET msg_{$template['type']}` command at the bottom of CiviCRM/CRM/Upgrade/Incremental/MessageTemplates.php seemed to work.

# Answer
> 1 votes
I'm sorry not to post in the comments but I do not have 50 points yet.

@Nic , can you explain your answer better? from version 5.4 exists the file MessageTemplates.php but (in WordPress) however does not update from 5.3.2 to 5.4

@Tellie , did you solve the problem?

# Answer
> 0 votes
I guess your system has either missing 'Event Online Receipt' message template or the template is not reserved. Check by running below query if it returns result.

```
SELECT id FROM civicrm_msg_template WHERE workflow_id IN (SELECT MAX(id) as id FROM civicrm_option_value WHERE name = 'event_online_receipt') AND is_reserved = 1

```

# Answer
> 0 votes
Have you ever found an fix for this issue? I got the exact same problem when upgrading from 5.3.2 to 5.6.0 or for that case any higher version then 5.3.2. I think it's a bug in the upgrader because I checked the civicrm\_msg\_template table to the original SQL schema and there are no differences.

---
Tags: upgrade
---


# Question
Title: MySQL v8.0 released. Will CiviCRM work with it?
MySQL 8.0 has been released. Will CiviCRM work with it? I tried migrating a test database to it, and CiviCRM under Joomla failed.

```
Oct 31 12:36:35  [info] $Fatal Error Details = Array (
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] =>  SELECT  v.label as label ,v.name as value, v.grouping as grouping FROM   civicrm_option_value_en_GB v,
       civicrm_option_group_en_GB g WHERE  v.option_group_id = g.id   AND  g.name            = 'languages'   AND  g.is_active       = 1  AND v.is_active = 1  AND ( v.component_id IS NULL  OR v.component_id IN (SELECT id FROM civicrm_component WHERE name IN ("CiviEvent","CiviContribute","CiviMember","CiviMail","CiviReport","CiviPledge")) )  ORDER BY v.weight [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'grouping FROM   civicrm_option_value_en_GB v,
       civicrm_option_group_en_G' at line 1]
    [type] => DB_Error
    [user_info] =>  SELECT  v.label as label ,v.name as value, v.grouping as grouping FROM   civicrm_option_value_en_GB v,
       civicrm_option_group_en_GB g WHERE  v.option_group_id = g.id   AND  g.name            = 'languages'   AND  g.is_active       = 1  AND v.is_active = 1  AND ( v.component_id IS NULL  OR v.component_id IN (SELECT id FROM civicrm_component WHERE name IN ("CiviEvent","CiviContribute","CiviMember","CiviMail","CiviReport","CiviPledge")) )  ORDER BY v.weight [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'grouping FROM   civicrm_option_value_en_GB v,
       civicrm_option_group_en_G' at line 1]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info=" SELECT  v.label as label ,v.name as value, v.grouping as grouping FROM   civicrm_option_value_en_GB v,
       civicrm_option_group_en_GB g WHERE  v.option_group_id = g.id   AND  g.name            = 'languages'   AND  g.is_active       = 1  AND v.is_active = 1  AND ( v.component_id IS NULL  OR v.component_id IN (SELECT id FROM civicrm_component WHERE name IN ("CiviEvent","CiviContribute","CiviMember","CiviMail","CiviReport","CiviPledge")) )  ORDER BY v.weight [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'grouping FROM   civicrm_option_value_en_GB v,
       civicrm_option_group_en_G' at line 1]"] )

```

The SQL below runs happily against MySQL 5.7 whilst it fails against MySQL 8.0 with

> "SELECT" is not valid at this position for this server version, expecting '(', WITH

SQL:

> SELECT v.label as label ,v.name as value, v.grouping as grouping FROM civicrm\_option\_value\_en\_GB v, civicrm\_option\_group\_en\_GB g WHERE v.option\_group\_id = g.id AND g.name = 'languages' AND g.is\_active = 1 AND v.is\_active = 1 AND ( v.component\_id IS NULL OR v.component\_id IN (SELECT id FROM civicrm\_component WHERE name IN ("CiviEvent","CiviContribute","CiviMember","CiviMail","CiviReport","CiviPledge")) ) ORDER BY v.weight

Replacing the first line with:

> SELECT v.label as label ,v.name as value, v.grouping as \`grouping\`

solves the problem.

Clearly some work is needed before CiviCRM will work with MySQL 8.0

# Answer
> 1 votes
Clearly CiviCRM won't work with MySQL 8.9 yet; at least not in my environment.

---
Tags: mysql-8.0
---


# Question
Title: Redirect to dashboard instead of redirect to add form
I've installed wordpress Version 4.9.8 with civiCRM.

Now i have create one new menu name is "userdata"

But when i click on menu "Userdata" it will redirect to the dashboard. Instead of dashboard it will show userdata add form.

# Answer
> 2 votes
Drp, Welcome to stackexchange!

I guess userdata link is the one you have created through extension/plugin and is also registered using xml and have menu rebuild. When menu link is not registered in CiviCRM it will default redirect to CiviCRM dashboard page.

If you haven't registered than

1. Register menu link using hook\_civicrm\_xmlMenu.
2. Rebuild menu by running /civicrm/menu/rebuild?reset=1 or Navigate to CiviCRM \>\> Administer \>\> System Settings \>\> Cleanup Caches and Update Paths \>\> Cleanup Caches.

HTH

Pradeep

---
Tags: wordpress, php, civicrm-buildkit
---


# Question
Title: How to allow a user 'edit' on activities?
Users have ACL 'edit' access to a group, and can access the contacts in the group OK. They can create an activity, but then cannot edit it - for each activity they just get 'View' and 'File on Case' possibilities and not 'Edit'. There are no permissions to edit activities - only view and delete. How can I allow them to edit activities? Using 5.6 and Drupal

# Answer
I fixed this problem by changing ACLs. Originally the user was in role 'A' and the contact where they could create but not edit an activity was in group 'B' - and role 'A' had edit access to group 'B'. By changing the target contact to be in the same group as the 'A' role and giving that role 'edit' access to itself (its group) then they get edit access to activities. As it happened, putting the target contact into this group is OK but this might not always be the case. Seems like 'edit activities' should be a permission - this has been discussed before.
> 2 votes

---
Tags: drupal, activities, acl
---


# Question
Title: Donors who gave the same amount in X and Y year
Is there a report in the Current version of CiviCRM that can tell us this? https://civicrm.org/extensions/advanced-fundraising-reports seems to have reports that will show if the giving is increased or decreased year to year, but not if it's exactly the same. Thanks!

# Answer
I don't think there is such a report. I would probably look at using Summary Fields extension and then adding a new calculated field that does your calculation - and then report on that.

In drupal I would also consider doing this in Views and using eg views\_calc to do the calculation for me instead of creating a calculated field
> 1 votes

# Answer
I am going to try petednz's approach using Views Calc, but I hacked together a quick MySQL query that pulled me most of what I wanted

```
select year(receive_date) as year,(select display_name from civicrm_contact where civicrm_contribution.contact_id = civicrm_contact.id) as Name, contact_id, SUM(total_amount) as Gifts
from civicrm_contribution
where (receive_date >= '2015-11-01' and receive_date <='2016-11-01') or (receive_date >= '2016-11-02' and receive_date >= '2017-11-01') or (receive_date >= '2017-11-01' and receive_date >= '2018-11-02')
group by contact_id, year, financial_type_id
having financial_type_id in (11, 12, 15, 25, 26)
ORDER BY name

```

Perhaps it can help someone else
> 1 votes

---
Tags: civireport
---


# Question
Title: Which template is used for receipts sent from admin entry and renewal of memberships?
If I go into CiviCRM and create or renew a membership as opposed to them doing it themselves online, which template is used for the receipt? Specifically I mean if you check the "send confirmation and receipt" box at the bottom of the membership form.

Is it "Memberships - Signup and Renewal Receipts (off-line)?" I think it's the "off-line" part that's throwing me off so I just wanted to confirm. Thanks!

# Answer
It's this one

Memberships - Signup and Renewal Receipts (off-line)

I often get a bit confused too. Best thing to do if in doubt it to make a minor amendment and do a test. You can easily revert back to the default afterwards.
> 4 votes

---
Tags: civimember, receipts
---


# Question
Title: Ran direct SQL update to bulk update contact names, changes not appearing until editing and saving
I'm finishing up a migration to CiviCRM from a homegrown Python application I wrote, and without going into too much detail as to the why, I needed to do a bulk update of all the contact name fields in the civicrm\_contact table using a spreadsheet dump from the old application.

I wrote a script that loops over the rows in the spreadsheet and runs an update statement on each record in civicrm\_contact table using the external\_identifier field to match.

This all seems to have run fine, but when I go to the contact in CiviCRM the old values are still there. However, when I click at the top of the contact screen to put the name fields into edit mode, the new values are in the form fields, and when I hit save the new values appear.

Is there some caching going on such that this will fix itself, or does updating the name fields directly as I did have some other implications/consequences I should be aware of? Thanks.

# Answer
> 6 votes
It sounds like you imported the `first_name` and `last_name` values - but the value at the top of the record is the `display_name`. You have two options:

* Use your SQL script to update the `display_name` accordingly.
* Export ONLY the `contact_id` of the affected records (or all records). Reimport the contact ID via the "Import Contacts" functionality. All records will be resaved when you import the contact ID and the `display_name` is recalculated on save.

Incidentally, this is a good if fairly harmless example of why directly updating the database via SQL is usually a bad idea. If this were imported via the API, the display name would have been recalculated. In this case, there was no data loss - but if you had tried updating, e.g. donation amounts, the lack of corresponding changes to your line item and financial transaction tables would be difficult to recover from!

---
Tags: contacts, database, sql
---


# Question
Title: Intermittent "Your browser session has expired and we are unable to complete your form submission" errors
In the midst of a fund drive and we're seeing intermittent instances of the message "Your browser session has expired and we are unable to complete your form submission. We have returned you to the initial step so you can complete and resubmit the form. If you experience continued difficulties, please contact us for assistance." on our contribution page.

This is on WordPress, CiviCRM 5.6, using the latest version of the Stripe plugin.

Nothing jumps out at me in the logs -- I do see some weird permission denied on wp-blog-header.php messages but those don't seem to be related in terms of the timestamp, and the site's behaving fine from what I can tell.

Any ideas on what might be causing this and how best to troubleshoot further? Thanks.

# Answer
Based on further investigation and discussion this seems to have been related to the WP Super Cache "Don’t cache pages with GET parameters. (?x=y at the end of a url)" setting being disabled. Once we got a bit of a spike in donors some people started seeing the error, but luckily a donor notified us so we caught it pretty quickly, and I was able to flip back to a Gravity Forms donation form as a stopgap while we did some troubleshooting. Live and learn.
> 5 votes

---
Tags: civicontribute
---


# Question
Title: membership source field not displaying in reports or exports sometimes
When doing a find or an export, the 'source' fields for memberships is blank for some records. For the records where it displays, its obviously been populated automatically when the membership is set up offline. For the records where it is blank, if I view the record, the value is there and is the same automatically created values as the ones that did display. If I edit and then save without making any changes, then that membership behaves as it should.

I'm using CiviCRM 4.7.24 but can't see anything in subsequent release notes that relates. It would be difficult to try on the demo system because most of the registrations come through correctly.

# Answer
The fact that the record displays correctly on save suggests that there's a difference between how correct and incorrect values are recorded in the MySQL database. I've seen this happen on multi-select custom fields when you import values with a comma rather than a value separator. The field LOOKS ok, but it's not stored correctly - but on save, the form corrects the data.

If you view the underlying MySQL table in a tool that supports showing hidden characters, I'm guessing you'll find one missing (or present) in the incorrect records.

UPDATE: To see if you can view hidden characters, try inserting one into the database. E.g.: `INSERT INTO civicrm_worldregion (name) SELECT CONCAT('a', UNHEX(01), 'b');`

If I view that in the MySQL CLI client, I can't see it: `mysql> SELECT name FROM civicrm_worldregion ORDER BY id DESC LIMIT 1;
+------+
| name |
+------+
| ab |
+------+
1 row in set (0.00 sec)`

I also can't see it from my command line:

`~/ » mysql temp -e 'SELECT name FROM civicrm_worldregion ORDER BY id DESC LIMIT 1'
+------+
| name |
+------+
| ab |
+------+`

However, if I pipe to `vim` then it appears as: `name
c^Ab`

That `^A` is in blue, which indicates it's not actually "caret then A" but rather "control character 0x01".
> 1 votes

---
Tags: civimember
---


title: CiviRule Minute Delay not working

text:
# Question
Title: CiviRule Minute Delay not working
I've created a few rules with CiviRules that trigger an email. They all work perfectly as long as I don't add a delay. I've tested adding a 1-minute delay with different types of rules but the email never gets triggered?

The job appears in the civicrm\_queue\_item table but doesn't get released

The job log for CiviRules delayed actions says success

Using CiviCRM 4.7.27 and CiviRules 1.15

I did further testing on my local environment and it works as expected when I changed the site's timezone to the one I live in.

Update: The emails were sent in the end but 11 hrs later even though the release date was correctly set to 1 minute later in the civicrm\_queue\_item table

# Answer
> 2 votes
The scheduled job for delayed civirules (Process delayed civirule actions (Always)) should be set to always. Can you check if your cron properly executes the CiviCRM scheduled jobs?

# Answer
> 1 votes
You could try upgrading to the latest CiviRules version? I recommend doing this on a test version first and always backing up your existing rules before you do.

---
Tags: civirules
---


# Question
Title: My site goes to maintenance mode spontaneously
My site goes to maintenance mode spontaneously almost every day. I am advised by users.

Everything works fine when I put it out of maintenance mode.

Any explanation is welcome

(Drupal 7.59 / Civicrm 5.4.0)

# Answer
> 2 votes
The error came from the Backup & Migrate Module : I had an error when I wanted to access the "Schedule" folder. When I unstalled the Module, the error disappeared.

# Answer
> 2 votes
I had a problem with the Backup and Migrate module where this would happen. There is a setting to put into maintenance mode while the backup is running. But the backup would error out and never turn off maintenance mode.

# Answer
> 1 votes
Can be a number of reasons with Drupal, I would imagine it's a probably on the Drupal side and not Civicrm though.

There could be something doing it in a module etc. etc, have to look at error log around the time it switches into maintenance.

# Answer
> 1 votes
Go to Reports -\> check the dblog (Recent Log Messages) and see if you can find out what and when is putting your site into maintenance mode.

---
Tags: system
---


# Question
Title: Is it possible to display Event Custom Data when openning a pertaining Webform?
When you open a Webform for an existing Contact, the Webform displays all the Contact info, including Contact Custom Data.

But, if the Webform contains Participant Custom Fields which had previously been filled, those are not populated, and you are blind for modifications.

Is there a way to have those Participant data displayed as well as Contact data ?

# Answer
> 0 votes
My notes suggest we added this feature about 7 months ago and you should be able to use pid1=xxx

Therefore using a url such as /node/92?pid1=15215 as a user who has permission to see the Contact involved should see the Contact and the Participation data load on the webform

If you have any problems doing so pls ping me and i will hunt down where our fix got to, but assume we pushed it back to core webform\_civicrm

UPDATE

Scenario: Contact xx is registered to Event A and Event B.

Now, if "cid1=xx" is added to the URL - it loads all the participant information of the contact for Events included in the webform and fills the webform. So both event A and Event B will be chosen as selected. Lets say the participant id for event A is yy and the event B is zz.

With our changes(not yet submitted to core) - If a user adds "pid1=yy" to the URL, it will only load the event A information, giving the user the option to update their participant record values via the webform.

So a webform loaded with - "cid2=204&pid2=54" will update participant id 54 information attached to contact id 204.

This has not been pushed upstream (ie to core) as we would need to check if it doesn't harm any other components and create a PR if it seems to be a good addition.

---
Tags: webform-civicrm, participants
---


# Question
Title: Error al introducir un contacto -- Entered a contact name incorrectly
He introducido como segundo nombre el primer apellido de un contacto: Irene Martínez Mas. Cómo puedo corregirlo? La aplicación me dice que no tengo permiso para hacerlo.

I have entered as the second name as the first name of a contact: How can I correct it? The message tells me that I do not have permission to do it.

# Answer
> 1 votes
Puede ser que tu registro de usuario no incluye el permiso "CiviCRM: editar todos los contactos" - tendrias que pedir al administrador del sistema que añade este permiso a un perfil que está asociado tu registro de usuario (e.g. personal, editor, etc.).

Espero que esto ayude!

Tamar

---
Tags: contacts
---


# Question
Title: I am trying to insert custom tab into Activity tab but it is not working
I am creating new extension.
I am adding a new custom field into Activity tab but it's not working

## //Creating a custom group for survey

```
function custom_group_create_survey(){
$survey_custom_group = array(
    "id" => "10",
    "name" => "API_survey",
    "title" => "API survey",
    "extends" => "Activity",
    "extends_entity_column_value" => [
        "1"
    ],
    "style" => "Inline",
    "collapse_display" => "1",
    "weight" => "   3",
    "is_active" => "1",
    "table_name" => "civicrm_value_API_sur__5",
    "is_multiple" => "0",
    "collapse_adv_display" => "0",
    "created_id" => "2",
    "created_date" => "",
    "is_reserved" => "0",
    "is_public" => "1"
);

try{
    $result = civicrm_api3('CustomGroup', 'create', $survey_custom_group);
}
catch (CiviCRM_API3_Exception $e) {
    // Handle error here.
    $errorMessage = $e->getMessage();
    $errorCode = $e->getErrorCode();
    $errorData = $e->getExtraParams();
    return array(
        'is_error' => 1,
        'error_message' => $errorMessage,
        'error_code' => $errorCode,
        'error_data' => $errorData,
    );
}

return $result;

```

}

```
function custom_field_create_survey() {
$params = array(
    'custom_group_id' => 10,
    'name' => 'test_textfield2',
    'label' => 'Name1',
    'html_type' => 'Text',
    'data_type' => 'String',
    'default_value' => 'abc',
    'weight' => 4,
    'is_required' => 1,
    'is_searchable' => 0,
    'is_active' => 1,
);

try{
    $result = civicrm_api3('CustomField', 'create', $params);
}
catch (CiviCRM_API3_Exception $e) {
    // Handle error here.
    $errorMessage = $e->getMessage();
    $errorCode = $e->getErrorCode();
    $errorData = $e->getExtraParams();
    return array(
        'is_error' => 1,
        'error_message' => $errorMessage,
        'error_code' => $errorCode,
        'error_data' => $errorData,
    );
}

return $result;

```

} ##

I am calling these functions into following hook

##

```
function surveytab_civicrm_install() {
custom_group_create_survey();
custom_field_create_survey();

```

\_surveytab\_civix\_civicrm\_install(); } ##

# Answer
I have an example of how I deal with creating custom groups and fields in an extension here: https://lab.civicrm.org/partners/civicoop/dmgeneriek/tree/master/CRM/Dmgeneriek/ConfigItems

I recommend avoiding using hard coded custom group id's in your code.
> 1 votes

---
Tags: api, hooks, civix
---


# Question
Title: recent CRON error on WP - after upgrade to 5.6.x
Recently updated to 5.6.1 (skipped a couple of the 5.x versions but the rest of the upgrade seems to have been successful). Running WP 4.9.8 / php 7.1.5

After the update I started getting 'Cron not running' errors in Civi. I can force scheduled tasks from Admin - System Settings - Scheduled jobs, but the cron I've had running for (at least) a year has stopped.

From ssh I run the same cron command:

> /usr/bin/php-5.4-cli /var/sites/h/hbb.org.uk/wp-cli.phar --user=XXX --url=https://hbb.org.uk --path=/var/sites/h/hbb.org.uk/public\_html/ civicrm api job.execute auth=0

and get the error below:

> Parse error: syntax error, unexpected '$this' (T\_VARIABLE) in /var/sites/h/hbb.org.uk/public\_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php on line 1121

It doesn't look like something wrong with my cron but with DAO.php (which I admit I have no idea what it is)? Am I passing too many arguments / not enough? Doesn't look like that kind of error.

Did something change in the last upgrade or two? The docs still suggest the cron formatting I have.

Thanks in advance.

# Answer
> 1 votes
Based on https://docs.civicrm.org/sysadmin/en/latest/requirements/#php-version php 5.4 is not supported in the latest 5.x version. As 5.4 is a very old vrsion of php, any chance you or your host can get you to php 7.1?

---
Tags: wordpress, upgrade, cron
---


# Question
Title: Development on a plugin - How to transfer values
I have created a new plugin structure using civix. It has created the elements I wanted in the database.

I have used dogregistry\_civicrm\_tabset to add a tab to my contacts pages. I used civix to create a page with a php file and a tpl file.

The question I have is how do I transfer a value to the page php file? I would like to send it contact ID so I can query the database for the entries for that contact but I'm not sure how to do that or whether it is stored already in a variable I can tap into?

Thanks for your help. Norm

# Answer
> 2 votes
Ok, I think I figured this bit out by using...

$this-\>\_contactId = CRM\_Utils\_Request::retrieve(...

and making sure the calling url has cid={$contactId} included. I'm getting the contactID in the php code, which will allow me to execute the queries and such I need to list out the details.

Norm

---
Tags: extension, developer, civix
---


# Question
Title: Been searching high and low... best approach for dispaying member information in WordPress?
I'm working on a website that needs to display customized sets of membership information.

The kind of thing I’m going for:

* CiviCRM custom fields indicate that member serves in a particular
committee, and their role. Say, the Board of Directors.
* On the WordPress site, the Board of Directors page lists a grid of members, and their roles.
* The site also shows those activities on a member’s profile page.

An example of the intended outcome: https://caims.ca/committee/executive/

I’ve been going through documentation to find a plausible approach, but I don’t see a clear path for the task as a whole. For each sub-task, there seem to be lots of possibilities, but no glowingly correct approach.

I’ve come across these possible steps, and possible tools:

1. Gathering “sets” of users (e.g., members who who are currently on the organization’s board )

* smart groups
    * saved searches
    * tags
    * member directories
    * Drupal-esque views
2. Packaging those sets up for transfer to WordPress

* exports
    * saved searches
    * custom-coded WordPress plugin
3. Displaying those sets in WordPress

* shortcodes
    * Pods custom fields
    * Toolset custom fields

I’m thinking about finding a developer to do some custom code to link things up.

At this point, I imagine I would have come across a recognizable method if there was one. But it seems prudent to make sure I’m not missing a direct solution. Thanks in advance for your help!

# Answer
If you are looking to contribute funding, it would be best to direct some funding to those pursuing creating Drupal Views like tools for Wordpress. Please see this thread How do you approach "things that you would use Drupal views for" in WordPress?.
> 2 votes

---
Tags: wordpress
---


# Question
Title: Drupal Rules - Condition "Civicrm Contact has email" appears to not be working
*The desired outcome was to create a drupal user record if and only if an email exists on the contact - when a membership was created/updated.*

To do this I wanted to add the condition "CiviCRM Contact has Email".

Testing this on multiple sites I've come to the conclusion that it doesn't appear to be working as advertised - it's not returning true when the associated contact has an email.

I've tested using these two stripped down rules - (It's not working on civicrm contact is updated either) - pasted below.

The only think I can think off that could be causing this is that the data selector is not correct? I tested this by outputting this using the debug action but perhaps it needs an ID not a "contact" or vice versa? I can't see any errors in the drupal log that would indicate this though. The rule is returning successfully - it's not generating any warnings.

Membership update

```
{ "rules_test_2" : {
    "LABEL" : "Test 2",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "civicrm", "rules", "devel" ],
    "ON" : { "civicrm_membership_edit" : [] },
    "IF" : [
      { "civicrm_entity_contact_hasemail" : {
          "contact" : [ "civicrm-membership:contact-id-contact" ],
          "location" : "0"
        }
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Has email" } },
      { "devel_debug" : { "value" : [ "civicrm-membership:contact-id-contact" ] } }
    ]
  }
}

```

Contact update

```
{ "rules_test" : {
    "LABEL" : "Test",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "civicrm", "rules" ],
    "ON" : { "civicrm_contact_edit" : [] },
    "IF" : [
      { "civicrm_entity_contact_hasemail" : { "contact" : [ "civicrm-contact" ], "location" : "0" } }
    ],
    "DO" : [ { "drupal_message" : { "message" : "Has emali" } } ]
  }
}

```

# Answer
https://github.com/eileenmcnaughton/civicrm\_entity/blob/7.x-2.x/civicrm\_entity.module#L3237

remove the ampersand from the $contact parameter

```
function civicrm_entity_contact_has_location_element_email($contact, $location_type_id) {

```

This is a bug, can you make an issue in the CiviCRM Entity project issue queue? I need to trace back how this code got that way, and see if there's any other reasons why it is as it is now before I put it into the release

But I can't think of any reason why it should
> 2 votes

---
Tags: drupal, civicrm-entity, drupal-rules
---


# Question
Title: Primary address being set to the wrong address
I am importing a number of custom contact types.

I am importing them with a "Main" address and "Postal Address" location which I created.

The default location is set to "Main".

However, when I import the Primary location is being set to an empty "Home" location which I do not want at all. How can I force it to make Main the primary location by default?

# Answer
> 1 votes
I think when you import if you choose "Primary" rather than "Main" from the drop-down options it will do both for you - set the address as location Main and set it as the primary. This is based on you saying you set Main as the default location. (I may not have entirely gotten your question as you mentioned another custom location but hopefully, this gives you something to start with.)

---
Tags: addresses, data-import
---


# Question
Title: Is there a way to regenerate the display and sort names?
After changing the display settings (/civicrm/admin/setting/preferences/display) for sort\_name or display\_name, is there a way to regenerate the sort\_names and display\_names currently in the database to the newly configured format?

# Answer
> 4 votes
As mentionned here :

* You can export the first name, last name and the internal ID
* Re-import the data by matching the internal ID

This process should regenerate the sort name and display name based on the current settings.

# Answer
> 2 votes
I dont think there is one right now, but the way to do it would probably be:

a. Create a a job for this in api/v3/Job.php

b. Do it similar to the address geocoding job. This is primarily because you could have lots of contacts and hence having an offset and a limit will be useful for some orgs. The job could potentially take a long time

c. There probably are functions in the Contact BAO to generate the sort/display name that you can reuse (some refactoring of the code is probably needed here)

# Answer
> 2 votes
If you have any familiarity with sql, the update statement is straight forward. Of course, test first in a test environment.

Here is one that would work for individuals with sort name like Smith, John and display name like John Smith.

```
update civicrm_contact
set    display_name = concat(first_name, " ", last_name),
       sort_name = concat(last_name, ", ", first_name)
where  contact_type = 'Individual'

```

If you have a lot of contacts and don't want to update them all at once you could add

```
and id between 1 and 5000 -- or whatever and increment the numbers manually

```

You'd also might need a statement for organizations and households, but since there is really only one field to work with for them, I'm not sure any change in sort order or display would change these.

# Answer
> 2 votes
I came across this issue today. I needed to update the display name after an import (there were reasons for not using the API to create in this instance).

I am using v5.6.1 (latest at the time of writing) and unfortunately the Export and Re-Import did not work for me as I could not choose to match on Contact\_ID. It may well be that the import function has changed since the original question, or I just could not find it...

I ended up using the v4 API instead - if you have a collection of records you want to update, use the Contact::Update call. I wanted to update all of my records, so I just used the GUI to specify Contacts of Type 'Individual' where the contact ID was great than 2 (after the admin).

The only issue I had was a timeout somewhere and so I did them in 10,000 batches. I could have done this in PHP but it was a simple fix without coding.

**PLEASE NOTE WELL** This works well for basic records - if you have contact subtypes and attached custom data, you may find that these are removed during a basic update

# Answer
> 1 votes
We now use the following SQL to accomplish the outcome. Still I think it would be better to include this in the Update Greeting scheduled task

```
# SET DISPLAYNAME (first,middle,last)
UPDATE civicrm_contact
SET    display_name = LTRIM(RTRIM(CONCAT(first_name, " ", middle_name, " ", last_name))),
       sort_name = LTRIM(RTRIM(CONCAT(last_name, ", ", first_name, " ", middle_name)))
WHERE  contact_type = 'Individual'
AND    first_name IS NOT NULL AND middle_name IS NOT NULL AND last_name IS NOT NULL;

# SET DISPLAYNAME (first,last)
UPDATE civicrm_contact
SET    display_name = LTRIM(RTRIM(CONCAT(first_name, " ", last_name))),
       sort_name = LTRIM(RTRIM(CONCAT(last_name, ", ", first_name)))
WHERE  contact_type = 'Individual'
AND    first_name IS NOT NULL AND middle_name IS NULL AND last_name IS NOT NULL;

```

---
Tags: civicrm-home
---


title: How to add custom field using API?

text:
# Question
Title: How to add custom field using API?
I want to add a custom field use for activities (meeting)?
I did that using **administrator -\> customize data and screen -\> custom fields**
How can I achieve it by API 3.

# Answer
> 4 votes
Following API call should do it.

`$result = civicrm_api3('CustomField', 'create', [
 'custom_group_id' => "GROUP_NAME",
 'label' => "CUSTOM_FIELD_LABEL",
]);`

Replace label and group name accordingly.

# Answer
> 3 votes
You can use the API CustomGroup create to create a custom group and the CustomField API to create a custom field. I'd recommend playing with the API explorer to get exactly what you need.

---
Tags: api, extension
---


# Question
Title: Is there an area in CiviCRM (or a way) for people involved in a case to communicate privately?
When a new case is set up, we need to let the parties involved with that case communicate privately and have their messages and shared docs only accessible to them? Like a shared, but private, message board. Is this possible without using an 'outside' tool?

# Answer
You can add BuddyPress in and with the additional BuddyPress CiviCRM plugins it will sync users. Think Facebook and you've got the idea. You can make things private or not, do PM's, do groups, etc.
> 2 votes

# Answer
Also take a look at iflychat. It's technically an outside tool but can be embedded in wordpress so appears as if it's part of the site. It can have private chat rooms and files. https://iflychat.com/installation/wordpress-chat-plugin. It also has drupal and joomla plugins.
> 0 votes

---
Tags: wordpress, civicase, configuration
---


# Question
Title: Event receipts for paid events contains extraneous information
Currently using CiviCRM 5.3.2 and drupal 7.60

Receipts for events paid via PayPal have extra information related to contribution.

**To reproduce issue:**

1. Add custom fields of your choice for Contributions
2. Create a paid event and assign `PayPal Standard` payment processor.
3. Enable online registration for the event and set `Send Confirmation Email` to `Yes`.
4. Register a participant for the event.
5. Check the receipt received and see if you get Contribution related custom fields in the email.

Anyone is facing this issue? May be with other payment processor?

# Answer
> 3 votes
After debugging I found that the code which generated the message values for contribution was also getting executed for Events. We just added a condition to check if its Contribution in `CRM/Contribute/BAO/Contribution.php`.

```
if ($this->_component == 'contribute') {
      $groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', NULL, $this->id);

  $customGroup = array();
  foreach ($groupTree as $key => $group) {
    if ($key === 'info') {
      continue;
    }

    foreach ($group['fields'] as $k => $customField) {
      $groupLabel = $group['title'];
      if (!empty($customField['customValue'])) {
        foreach ($customField['customValue'] as $customFieldValues) {
          $customGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues);
        }
      }
    }
  }
  $values['customGroup'] = $customGroup;
}

```

Do we need to clean up this code? or anyone have any thoughts so we can add issues on Lab and raise PR for same

---
Tags: civievent, civicontribute
---


# Question
Title: Searching for someone not in a relationship
We're using CiviCRM to primarily build a network of activist groups around the country. There are "area organisers" and people they are linked with. We are using the relationship function to link people together. It would be really helpful to be able to search for people who haven't yet been linked to an area organiser (because there isn't one yet in their locality), but I can only work out how to search for relationships between specific individuals. Is there a way to search for everyone who doesn't yet have a relationship with anyone else in the database?

# Answer
> 6 votes
The 'Include/Exclude' search is very handy for situations like this:

1. create a group of all contacts of interest
2. create a group of those who DO meet some criteria
3. use include/exclude to include group 1 and exclude group 2 to produce those who DON'T meet the criteria

So in your case:

1. create a group of all people
2. create a group who do have a relationship (Advanced Search, open Relationships section, select relationship types of interest, search, save group)
3. go to `Search > Custom Searches > Include/Exclude search` include your 'all' group, exclude the 'has relationship' group (select either AND/OR - doesn't matter since you are not using tags but it is still required) Save as a group if you want.

If you want to use this often, create all 3 groups as smart groups.

# Answer
> 2 votes
One way is to export two lists to Excel and then use the power of Excel to find the missing ones.

1. Under Reports - Contact Reports, run the Relationship Report and under Columns check "Contact ID" so that it appears in the output.
2. From the Actions dropdown export that to CSV.
3. Under Reports - Contact Reports, run the Constituent Summary Report and under Columns check "Contact ID".
4. From the Actions dropdown export that to CSV.
5. Do something like described here to find the contact ids that are in the second list but not the first. Note you'll need to sort the lists by contact id first for this method to work. https://www.extendoffice.com/documents/excel/3124-excel-compare-two-columns-for-missing-values.html#formula

There are other ways to do it in Excel if you don't like that one above. Search the internet for something like "how to tell which values are missing from two lists in excel". If you're using LibreOffice or similar I'm sure it can be done too.

# Answer
> 2 votes
While this isn't an ideal fix, it's a quick one if you know SQL:

* Create a new group called "Contacts without relationship".
* Note the group ID. You can find the group id by hovering the mouse over the "Contacts" link of the group on the **Contacts » Manage Groups** page. In the screenshot below, you can see that the group ID of "Summer Program Volunteers" is "3".
* Run this SQL statement: `INSERT INTO civicrm_group_contact (group_id, contact_id) (SELECT '3', cc.id from civicrm_contact cc LEFT JOIN civicrm_relationship cr ON cc.id = cr.contact_id_a WHERE cr.id IS NULL AND cc.is_deleted = 0 AND cc.id IN (SELECT cc.id from civicrm_contact cc LEFT JOIN civicrm_relationship cr ON cc.id = cr.contact_id_b WHERE cr.id IS NULL AND cc.is_deleted = 0));`

Replace the "3" above with YOUR group ID before you run it.

Now, everyone without a relationship will be in your group.

Screenshot for group ID (click to zoom):

# Answer
> 0 votes
Either you can create a custom report to achieve that or can be done through CiviCRM API in a module code.

---
Tags: search, relationships
---


title: Private Files Readable

text:
# Question
Title: Private Files Readable
How can I fix this error on CiviCRM. Thanks.

# Answer
Preventing access to those files should be taken care of by `.htaccess` files.

You should have `.htaccess` files under `files/civicrm/ConfigAndLog`, `files/civicrm/upload`, `files/civicrm/custom` with content:

```
<Files "*">
  Order allow,deny
  Deny from all
</Files>

```

What webserver are you using? Is this on a hosted environment or your own server? The server needs to be configured to use `.htaccess` files

For Apache, see https://httpd.apache.org/docs/current/mod/core.html#allowoverride

For nginx, see other posts on this site - eg:
> 2 votes

# Answer
You need to check the permissions on the hosting server for the directories in the warning. The directory permissions should be set to 0755, or it may show as 755. The files within the directories should show 0644, or 644.
> 1 votes

---
Tags: files
---


# Question
Title: VBO (views Bulk Operation) to send mails, mailings, ans SMSs?
CiviCRM 5.6.0

Is it possible to use VBO (views Bulk Operation) to send mails, mailings, ans SMSs ?

How ?

# Answer
> 1 votes
Although CiviCRM entities are exposed to Drupal via CiviCRM Entity module, they are still not Drupal entities.

So in VBO even though you might think you can modify entity values to CiviCRM entities, it does not work very well at all.

Also in VBO even in Drupal you cannot send an email using this method. In VBO all you can do is modify entity values or execute a PHP script.

You would have to use a combination of VBO and Drupal Rules to send an email. And none of that would be recorded as a CiviCRM activity.

Not for me to ask, but using CiviCRM Scheduled reminders and inbuilt CiviMail would be a much easier option.

# Answer
> 0 votes
You can use VBO by creating a custom action. See Views Bulk Operations development guide (Drupal 7)

The CiviCooP E-mail API and SMS API extensions might be useful.

---
Tags: drupal-views
---


# Question
Title: How to use Views to send a Mailing to a Selection of Recipients?
Drupal 7.60, Civicrm 5.6.0

I want to give to my users the ability to send a mail or mailing to a selection of recipients, based upon some cross selection of fields values.

Views is a good tool for this cross selection and to get a recipients list.

But then, how can I pass this list to the Mailing Form ?

# Answer
I'm assuming what you have is a bunch of Drupal users that you are segmenting using Drupal field values.

Step 1 Go here civicrm/admin/synchUser?reset=1 and make sure all your Drupal users are in CiviCRM.

Step 2. Create a custom field for an individual. Make it Yes/No. Call it My Group or whatever. Make it searchable.

Step 3. Make sure that you have the custom field group added to the database config in settings.php /civicrm/admin/setting/uf?reset=1 so you can use it in Drupal Views.

Step 4. Create a view of CiviCRM contacts. Use a Drupal UID relationship so you can filter them into the group you want. Add the custom field you created in Step 2 to the view. Add a VBO filed. Modify the Entity value of the custom field. Bulk edit the custom field and set it to 1.

Step 5. Go to CiviCRM and search for contacts with the custom field set to yes. Add them to a new Mailing Group.

So you could have this as a smart group. You users just have to use VBO to add in the custom field value to update the smart group.
> 1 votes

# Answer
You can create mailing jobs and execute them programmatically.

Process:

1. Create a mailing
2. Create mailing job through code:
3. `$new_job = new CRM_Mailing_BAO_MailingJob();
 $params = array(
 'mailing_id' => MAILING_ID,
 'status' => 'Scheduled',
 'scheduled_date' => date('YmdHis'),
 'is_test' => 0,
 );
 $new_job->create($params);// Save job in database`
4. Execute mailing job through code:
5. `CRM_Mailing_BAO_MailingJob::runJobs();
 CRM_Mailing_BAO_MailingJob::runJobs_post();`

Hope that will lead you towards your goal.
> 0 votes

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


# Question
Title: Incorrect Month To Date in member dashboard
Member Dashboard shows following headings

```
October – (Last Month)  March (MTD) 2018 (YTD)

```

Obviously the month to date heading should be "November" rather than "March".

Where is civicrm getting its current month from?

# Answer
It's a bug. I've logged an issue here along with a fix See https://lab.civicrm.org/dev/core/issues/511
> 2 votes

---
Tags: civimember, dashboard
---