# Question
Title: What are my options for importing recurring contributions?
Our organization is currently transitioning into CiviCRM. We have some existing recurring contributions (with Paypal Standard) that are ongoing and we would like to import them into Civi. Why do we want to import them? Well, here is my current understanding of the situation:

When the monthly contribution amount is charged from the donor's card by Paypal, an IPN with the payment data is sent to our server. Civi processes the IPN and tries to relate it to an existing recurring contribution. If it finds the related recurring contribution, it creates a new single contribution record for the payment made. If it doesn't find a related recurring contribution, it gives an error.

So this is why we need to import (or somehow recreate) the recurring contributions. What are our options for that? I saw this wiki page, however in the Contributions tab inside a contact I can't find a "Submit Credit Card Contribution" button.

# Answer
Here is some relevant information I got from JonGold on this matter in a private chat in IRC. Posting the conversation in its entirety.

`[21:16] <borislav> hi
[21:16] <JonGold> hi
[21:17] <borislav> is this by any chance your answer here? http://stackoverflow.com/a/31733507/2762014
[21:18] <JonGold> yup
[21:18] <borislav> cool
[21:18] <borislav> how did you import the recurring contributions into your civi database?
[21:19] <JonGold> I used the command line CSV API import tool
[21:19] <borislav> ah!
[21:20] <borislav> could have thought of that myself, haha
[21:20] <borislav> so you first imported the contacts and then the recurring contributions?
[21:20] <JonGold> I'm looking at the CSV now. Here are my headers: "trxn_id","installments","frequency_unit","amount","invoice_id","start_date" ,"create_date",contact_id,"frequency_interval"
[21:21] <JonGold> Yes - I do a lot of migrations to Civi. I first import the first name/last name/external identifier. That way I can map external IDs to CiviCRM contact IDs.
[21:21] <JonGold> Though I realize that we've confused two different issues here.
[21:22] <JonGold> The IPN issue didn't involve me importing anything. I had a Civi client who switched from Drupal to Wordpress. So the database didn't change, nothing was imported. I just needed IPNs to show up at a Wordpress-based URL.
[21:22] <JonGold> But I've also imported plenty of recurring donations using the command line API CSV tool!
[21:24] <borislav> right, in that case you already had the recurring contribs in the civi database so you just needed to redirect the IPN. in my case I need to import them to the database
[21:24] <JonGold> What payment processor are you using?
[21:24] <borislav> Paypal Standard
[21:25] <JonGold> Hmm. I'm not sure how successful you're going to be, but I can give you some tips.
[21:25] <borislav> if you want to, answer my question here: http://civicrm.stackexchange.com/questions/7146/what-are-my-options-for-importing-recurring-contributions
[21:26] <borislav> or I can compile an answer with your tips and post it
[21:26] <borislav> whichever you prefer :)
[21:26] <JonGold> When you create a recurring donation in CiviCRM using PayPal Standard, Civi gives PayPal a string of data that it expects to get back. It includes the contact ID, recurring contribution ID, etc.
[21:27] <JonGold> So when PayPal sends its IPN ping, Civi is expecting to get that data back in a particular format.
[21:27] <JonGold> If it's getting the IPN data pinged to it and that contribution was created in a different CRM, the data won't be there.
[21:28] <JonGold> In theory, you can go into each IPN subscription in PayPal and change the data. I've done it manually. You can also possibly write a script. It's a huge pain.
[21:28] <JonGold> You can compile these answers - I don't think I need the Stack Exchange points :)
[21:29] <JonGold> My last client in your situation agreed that the option they'd take is to manually upload a list of recurring donations from a CSV (I forget whether it was compiled manually or exported from a legacy system)
[21:29] <JonGold> The recurring contribution records were still present in Civi so they could, e.g., search for recurring donors, but there were no IPNs, just the manually imported recurring donations.
[21:30] <JonGold> As each person's credit card expired, they would have that person restart the recurring payment through Civi. This may work differently with PayPal standard though.
[21:31] <JonGold> Also, to respond to your not seeing the "Submit Credit Card Contribution" button - I'm not sure that works with Paypal Standard, I'm afraid. Not 100% sure though
[21:39] <borislav> I had no idea that the paypal IPN data depends on what Civi sent to Paypal in the first place. this makes things much more complicated. for me it may not be worth it to do all of this. with not too many subscribers, it might make more sense to ask them to register for a donation again, this time with Civi's donation form
[21:40] <borislav> you have saved me a lot of time with this info, thank you
[21:40] <JonGold> no problem!`
> 2 votes

# Answer
My attempt at summarising Borislav's / John Gold's answer (above) for easier reading here:

If you're trying to import recurring contributions into Civi from a previous membership program / CRM, you *may* be able to write something that goes into paypal and changes the IPN data it gives civi, so Civi understands it. But it will be a pain.

Normally Civi gives PayPal Standard a string of data when you set up a recuring contribution, which it expects to give back; if the recurring contribution was set up in a legacy system, PayPal won't give the same string back, and therefore without changes, Civi won't understand it.

You could alternatively. manually upload recurring subscription data in a csv to Civi, so it's there to look through in Civi, but it won't have IPNs and won't continue to link to Paypal. Then as each person's card expired, they would have them restart the payment through Civi.

John Gold is unsure if the "Submit Credit Card Contribution" button will work with PayPal standard either.

***To me,***\- and we are looking at having to do this with my organisation - having to ask every member to set up their card again sounds like a right pain - and we are quite worried that we will lose a significant amount of members in the process, as people may well not set up their subscriptions again.

If anyone else has updates / more information about this / possible solutions to the original question, I would be very grateful. Thanks
> 2 votes

# Answer
Fuzion's Import API CSV extension has more fields than Import Contributions, and most importantly I think for the situation I am looking at, these include Recur Contribution ID.
> 2 votes

# Answer
Are those recurring plans in CiviCRM? If not then you *might* need to use something like Civi Banking to do the work for you. If they are then I think the options your talking about should become available.
> 1 votes

---
Tags: import, recurring-contributions
---


# Question
Title: Solved: Is this a bug - [civicrm.files] variable
Drupal-7.54 , CiviCRM-4.7.16 Multi-site / Aegir platform.

On a clean Drupal+CiviCRM instal the autogenerated path for the \[civicrm.files\] variable in 'Settings - upload directories' differs from the URL path generated in 'Settings - Resource URL'.

In Settings- Upload Directories the civicrm.files variable is: var/aegir/platforms/platform\_name/sites/***siteURL***/files/civicrm

In Settings- Resource URL the civicrm.files variable is: h t t p://siteURL/sites/***default***/files/civicrm/

The problem does not arise in a non-multi-site environment, where both paths point to 'sites/default/files/civicrm (as confirmed on the sandbox demo).

This also seems to affect the path to the files/civicrm/persist directory.

One effect of this seems to be on CKEditor: when the CKEditor configurator is used it creates files (e.g. crm-ckeditor-civimail.js) in the persist directory. But these files are ignored when CKEditor is used in Civimail (see Solved: How do I allow all tags in CKeditor, and 4.7.15 breaks civimail styles and templates (fullPage doesn't help) and maybe CiviMail template format in HTML not saving

# Answer
> 1 votes
UPDATE: A fix for multisites and Aegir setups will come out in CiviCRM 4.7.21. See https://issues.civicrm.org/jira/browse/CRM-193

---

The fix for our problem ended up being somewhat multidimensional.

The patch in https://issues.civicrm.org/jira/browse/CRM-19303 solved the issue of the autogenerated path for the \[civicrm.files\] variable in 'Settings - upload directories' differing from the URL path generated in 'Settings - Resource URL'.

Though the issue doesn't seem completely solved, the patch has very recently been merged https://github.com/civicrm/civicrm-core/pull/9409

(There is a bit of a rabbit hole that leads to https://github.com/civicrm/civicrm-core/pull/9053).

But this did not totally fix the problem for CKEditor as the CKEditor config file is being placed in the persist directory (instead of persist/contribute) and the persist directory kept returning a 403 error. Until CRM-19303 is fixed we circumvented it by allowing the vhost to read the persist directory instead of persist/contribute. We temporarily patched hosting\_civicrm to do this.

Aegir was also throwing some file permission errors when creating new sites, and appears to be a different issue, see https://www.drupal.org/node/2791953. We applied the patch which will likely get committed.

We had to enable the Aegir fix\_permissions and fix\_ownership modules for this, which are experimental, but somewhat necessary here.

For now you still need to manually run a Verify on the site after creating it.

Thanks to Kainuk (https://civicrm.stackexchange.com/users/110/kainuk) for his pointer and to Guillaume Boudrias from praxis.coop (https://www.drupal.org/u/gboudrias) for going down the rabbit holes to fix the problem.

---
Tags: drupal, issues, ckeditor, drupal-multi-site
---


# Question
Title: How do I override the default CKEditor configuration?
**The question**

Where/how can I override the default CKEditor configuration files in CiviCRM?

**Original issue / follow-up question**

We have a custom email template that uses `<html>, <head>, <body>`. When using CKEditor, if you paste the template in 'Source' and then flip back out of the source view the tags mentioned above are stripped out. This is because the CKEditor default setting is to strip these tags.

I've opened a follow-up question here: How can I use \<html\>, \<head\>, \<body\> tags in a mailing?

# Answer
To answer your question about how to modify CKEditor's config.js:

## In 4.6

You need to "hack" the config.js file within CiviCRM itself (packages/ckeditor/config.js). Editing this file will modify all instances of CKEditor in CiviCRM (angular and quickform add a few additional settings related to file uploads but they do both respect that file). If you don't see your changes right away, clear your browser's cache. Note that this file will be overwritten with every upgrade.

## In 4.7

4.7 adds a GUI in Display Preferences to modify plugins and button groups, and this will generate at least one config file named `crm-ckeditor-default.js` in your `files/civicrm/persist` directory (more files will be created if you click other tabs e.g. for CiviMail or CiviEvent). This file won't be overwritten during upgrades, but will be overwritten if you make changes from the GUI. There is also a new hook\_civicrm\_coreResourceList which you can use to specify a different config file depending on whatever logic you want like current page, current user, etc.
> 13 votes

# Answer
We had the same problem on a multisite / Aegir system and after much work solved this.

Our solution is detailed here: Solved: Is this a bug - \[civicrm.files\] variable
> 0 votes

---
Tags: civimail, tags, wysiwyg, ckeditor
---


# Question
Title: How to disable or fix the wysiwyg editor on civimail
Oh joy of wysiwyg editors, that are going to alter the html you have so carefully typed to be compatible with all the mail clients in their glorious diversities...

For some mailings at least, I'd like to be able to tell the editor to stay home and let me type my html directly, as the W3C gods intended. Unfortunately, the setting to change the editor (CKEDITOR, tinyeditor or textarea) doesn't seem to be taken into account in civimail (or ab testing)

Is this a cache that I couldn't clear after the change (it worked fine for "normal" mail sendings, just civimail that ignored the new setting)?

Is there a bit of code to hack to make it work?

# Answer
> 3 votes
**Editing markup**

The editor includes a "Source" button which can be used to edit markup directly.

**Using `<textarea>`**

Upgrade to v4.7!

**In depth**

CiviCRM v4.6 includes a pure-JS rewrite of the CiviMail frontend. Unfortunately, the old WYSIWYG abstraction couldn't adapt well to pure-JS, so CiviMail in v4.6 only supports one editor. (Specifically, CiviMail uses the `crmUiRichtext` directive which is hardcoded to CKEditor.) However, all other screens still use the old WYSIWYG abstraction.

v4.7 cleans things up by switching to a pure-JS WYSIWYG abstraction. The core ships with only two options (CKEditor and `<textarea>`). However, you can write an extension that defines alternatives (e.g. https://civicrm.org/extensions/tinymce ).

See also: https://civicrm.org/blogs/colemanw/big-changes-wysiwyg-editing-47

# Answer
> 0 votes
I know that's not exactly what you requested, but you might consider disabling the character escaping behaviour of the editor altogether.

Here is how.

# Answer
> 0 votes
This doesn't answer the question neither but it might help.

What I do to prevent CKEditor from striping/modifying the markup is disable CKEditor's Advanced Content Filter (ACF), editing the config.js file in `/path/to/civicrm/packages/ckeditor`, more info here.

```
config.extraAllowedContent = 'html;head;body;span;ul;li;table;td;style;*[id];*(*);*{*}';

[ ] // for attributes

{ } // for styles

( ) // for classes

```

# Answer
> 0 votes
The problem seems to be that the CKeditor configurator at *Administer-\>Custom data and Views-\>Display* persists the editor configuration in a file in `/media/civicrm/persist/crm-ckeditor-config.js` and that file is overwritten each time you touch the configurator.

It looks like CiviCRM does this by replacing the reference to the default config.js (in `packages/ckeditor` with a reference to the persisted config. So any configuration placed here is simply never read.

So I can't see any solution to this problem until there is a way to insert custom config directives into that persisted config. (Except for re-adding it every time you re-configure CKEditor...).

# Answer
> 0 votes
We had a similar problem of the CKEditor config not 'taking' on a multisite / Aegir system and after much work solved this.

Our solution is detailed here: Is this a bug - \[civicrm.files\] variable

---
Tags: civimail, wysiwyg
---


# Question
Title: Solved: How do I allow all tags in CKeditor
How do I set mailings to allow all tags? I'm using the latest D7 and Civi and have tried setting this via the GUI, but the editor still filters the code :-(

Below is the generated crm-ckeditor-civimail.js file (in files/civicrm/persist.):

```
/**
 * CKEditor config file auto-generated by CiviCRM (2017-02-13 20:10:38).
 *
 * Note: This file will be overwritten if settings are modified at:
 * @link http://ir.association.works/civicrm/admin/ckeditor
 */
CKEDITOR.editorConfig = function( config ) {
    config.toolbarGroups = [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
        { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
        { name: 'forms', groups: [ 'forms' ] },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
        { name: 'links', groups: [ 'links' ] },
        { name: 'insert', groups: [ 'insert' ] },
        '/',
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'colors', groups: [ 'colors' ] },
        { name: 'tools', groups: [ 'tools' ] },
        { name: 'others', groups: [ 'others' ] },
        { name: 'about', groups: [ 'about' ] }
    ];

    config.skin = "moono";

    config.allowedContent = true;
};

```

# Answer
> 1 votes
UPDATE: A fix for multisites and Aegir setups will come out in CiviCRM 4.7.21. See https://issues.civicrm.org/jira/browse/CRM-19303

After much work we managed to solve this. It was definitely a multisite / Aegir issue.

We had to go through some hoops and down some rabbit holes but you can find our solution detailed here: Solved: Is this a bug - \[civicrm.files\] variable

---
Tags: civimail
---


title: Drupal 7,x campaigns

text:
# Question
Title: Drupal 7,x campaigns
I'm just getting started with civicrm and I've noticed that campaigns are mentioned in a lot of instructional resources

However, I downloaded the latest instillation of civicrm and there's no campaign feature in the menu, and I can't find any campaign module that I've seen mentioned.

How do I activate campaigns?

# Answer
You may need to enable the Campaigns component: go to `Administer > System Settings > Components` and make sure CiviCampaign is enabled
> 1 votes

---
Tags: drupal
---


# Question
Title: What should the outbound SMTP configuration be for Office 365 Exchange?
I am trying to use Office 365 Exchange as the mail transport for CiviCRM, but get this error.

Failed to connect to ssl://smtp.office365.com:587 \[SMTP: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.office365.com:587 (Unknown error) (code: -1, response: )\]

I have looked at enter link description here, and links therein which seemed to indicate that a STARTTLS issue was fixed.

Office 365 Exchange has these instructions for SMTP connections: enter link description here

I am running a development system under Windows so don't have a mail server on board, and in any case don't want to overcomplicate things - performance isn't an issue.

Any suggestions?

# Answer
> 1 votes
Which version of civi are you using? https://issues.civicrm.org/jira/browse/CRM-14814 it's fixed on a fairly recent version of civicrm only

Another reason can be the confirguration of your network or your server: can you start a connection on port 587 to smtp.office365.com ?

However, before you spend too much time on it, last time I checked: \- smtp on office365 was limited in volume, ie find at low volume, but won't work for production \- 365 doesn't handle "+" notation, so and email to bounce+something@yourdomain.org won't end up in your bounce mailbox. This is needed to handle bounces in civicrm

so I would recommend you: if it's for testing purpose, use a gmail account if it's for production purpose, use an external provider to do the bulk mailing and integrate it with your civi, for instance sendgrid and this extension: https://civicrm.org/extensions/sendgrid-event-notification-processor

---
Tags: civimail, core
---


# Question
Title: Recurring contributions cancelled in Civi NOT cancelled in Authorize.net
Anyone having issues with recurring contributions being cancelled in Civi not being communicated to authorize.net in 4.7.9?

# Answer
> 1 votes
Turns out that this was an issue caused by the iATS extension - strange as that may sound - you will find details at the following link: https://github.com/iATSPayments/com.iatspayments.civicrm/issues/188

Whether or not the cancel recurring for PayPal ever worked is a separate question altogether (for us it never has).

# Answer
> 0 votes
Eileen McNaught and Joe McLaughlin have both indicated that apparently this has never worked - we must be in possession of some custom code that made this work in 4.4.7 and earlier, but apparently it is no longer functioning in 4.7.X - thanks for your help!

---
Tags: contributions
---


# Question
Title: How to create Drupal View of Participants with custom fields
I have events with custom fields. I want to show participants with the corresponding custom fields in a View. I can't find how to retrieve custom datas.

Is somebody have already created this kind of View?

Using Drupal 7.54 and Civicrm 4.7.16.

Thank you for your help.

# Answer
Create a new view.

Give the view a name

Show CiviCRM Participants

Create a page view perhaps, make sure there is a path

Continue

Add some fields, maybe you want the contact display name for instance The custom field will be available in a group "CiviCRM Custom \[custom\_group\_name\]" Add your custom fields...

Maybe you want only those participants for a given event?

Number of ways to do this, but lets just describe one way.

so lets say your View is at path "/event-participant-listing" Lets use a contextual filter, and filter by event id, so that "/event-participant-listing/1" would list participants for event with id 1

editing your view, Click the Advanced fieldset in the right column

Add a contextual filter "CiviCRM Events: Event ID"

Maybe set "When the filter value is NOT in the URL" to 'Display contents of "No results found"'

Make sure if you choose that to add a "Global: Text Area" to the "No Results Behavior"
> 1 votes

# Answer
This is a regression in 4.7. See issue CRM-20194: Only 'Contact' is treated at the end of civicrm/drupal/modules/views/components/civicrm.core.inc : $extendsContactSubtype = (('Contact'=== $dao-\>extends) && !empty($dao-\>extends\_entity\_column\_value)); Replacing this line by : $extendsContactSubtype = (!empty($dao-\>extends) && !empty($dao-\>extends\_entity\_column\_value)); seem to work (but I've not full tested).
> 0 votes

# Answer
There was a bug with this recently. Update to latest civi to solve. I posted a q about this (on phone or I'd link you)
> 0 votes

---
Tags: civievent, custom-fields, drupal-views
---


# Question
Title: Why are public files in Joomla admin directory?
I was attempting to lock down our Joomla admin folder with an additional Apache-level password, and discovered that there are some Civi resources under the admin folder that need public access (css, js, etc.). On the face of it, it seems to me this would be a bad practice (other public joomla resources do not seem to be under admin), but there are vast oceans of information that I don't know! Could someone explain (as briefly and simply as possible!) why these files are under www/administrator/components/com\_civicrm/civicrm/ rather than under www/components/com\_civicrm/ or such?

I suppose I should also say that I haven't knowingly put these resources under admin, so I am assuming they were placed there as standard Civi installation. If I've improperly configured Civi, then my question becomes: What did I do/not do to cause this?

# Answer
> 1 votes
I have found the same thing. I think there is a misalignment in the configuration, as the components settings file:

`* CIVICRM_UF_BASEURL - home URL for your site:
 * Administration site:
 * define( 'CIVICRM_UF_BASEURL' , 'http://www.example.com/joomla/administrator/');
 * Front-end site:
 * define( 'CIVICRM_UF_BASEURL' , 'http://www.example.com/joomla/');
 *
 */
if (!defined('CIVICRM_UF_BASEURL')) {
 define( 'CIVICRM_UF_BASEURL' , 'http://www.xyc.com');`

For the front end forms to work, it needs to be /administrator to load the resources, however the form then posts to this URL, which is not correct for unauthenticated users.

I am going to copy the relevant resources for now.

# Answer
> 0 votes
I've done this for now. You could update to lock down further if the file doesn't match.

```
            # if file exists, ignore
            RewriteCond %{REQUEST_FILENAME} !-f
            # rewrite css, js, images & other public
            RewriteCond %{REQUEST_URI} \.(?:css|js|jpe?g|gif|png|tiff|woff|woff2)$ [NC]
            RewriteRule ^components/com_civicrm/civicrm(/.*|)$ /administrator/components/com_civicrm/civicrm/$1 [L,NC]

```

---
Tags: joomla, core
---


title: How can I add a tag to a tag set?

text:
# Question
Title: How can I add a tag to a tag set?
Using CiviCRM 4.7.16. I create a new tag and I want to add it to a tag set. But when I click on the Parent Tag pull down menu, it only shows tags that have not been assigned to a set. Tag sets are not shown. This is the case when both creating a new tag and editing a tag. I can't see another way to add a tag to a tag set. Is this a bug?

# Answer
> 3 votes
You may be right that this is a bug in 4.7.16. Fortunately it has been solved in 4.7.17.

This release includes a redesigned tag management screen with numerous improvements.

Update: 4.7.17 has been released.

---
Tags: tags
---


# Question
Title: Drupal - MySQL support not included in PHP
I am getting the following error on install of CiviCRM:

PHP Configuration

MySQL support MySQL support not included in PHP.

I am running:

CENTOS 6.8

Apache 2.4.18

Drupal 7.54

CiviCRM 4.7.16

PHP 5.5.35

MySQL 5.6.35

The following lines of php.ini are uncommented

extension=pdo.so

extension=pdo\_sqlite.so

extension=pdo\_mysql.so

I cannot quite figure out this error and so far have found nothing in my search that leads me to a solution.

Anyone have some insight?

TIA

Gary

# Answer
CiviCRM is looking for the function `mysqli_connect()`, which is provided via the `mysqli` ("MySQL improved") extension in PHP.

To enable this, uncomment -

```
extension=mysqli.so

```

If that doesn't work, your next question may be: How to enable mysqli in PHP?
> 3 votes

---
Tags: drupal, php, mysql
---


# Question
Title: Retrofitting languages into English-based Install
I've been trying to work with CiviCRM 4.7 on Wordpress 4.7 in Bahasa Indonesia, and have been struggling a bit. I came across this post: localization on wordpress, which was somewhat helpful.

My quandary is this: I (like a lot of folks it seems) installed CiviCRM in English, and later went back to make it a multi-lingual site, and added the l10n and sql files for local languages. After doing some research, it seems as though the consensus is to install it in the local language from the get-go. However, now that I've already installed in English, and want to add a language, what is the best way forward?

I understand that one reason behind starting localization from the install is that the sql files help to populate option groups, message templates, etc. when CiviCRM is freshly installed. Is there some way, short of a total reinstall to essentially do a "refresh" so that these settings can be copied into the database?

# Answer
To change it to the local language you do not need to make it a multi-lingual site as far as CiviCRM is concerned? I assume you mean that you installed the language pack. If you then want to change the language of your CiviCRM install you go to Administer/Localization/Languages,Currencies,Locations and change the language to what you want it to be. Unless I have completely misunderstood your question, but then you might want to expand a little on what you want exactly :-)
> 1 votes

# Answer
In the end, I created a separate installation of CiviCRM in the local language, and then exporting the tables identified in the localization SQL file, and porting them into my original, English-based install. This was particularly important to ensure all of the dropdown options, not just the nav menus, were translated. Seems to have done the trick!
> 1 votes

---
Tags: localisation
---


# Question
Title: Creating reports with custom fields relating accounts and contacts - how does it work?
I am looking for a CRM to install that can do the following:

* Create custom field in account where I can select/link one or more contacts that are the founder of the account (firm)
* Create a custom field in the account with the founding date of the firm
* Create a school field in the contacts

And here comes the trick:

> I would like to create reports that show for example: all account/firm names that are founded within a specific date range with contacts linked in the custom founder field that have visited a specific school.

So in summary what I would like to accomplish is to generate a list of accounts that have been founded within a specific date range by founders from a specific school. I think I need custom fields since one founder can be the founder/employee of more than one account.

Does this work with CiviCRM and if so, how do I do it?

Thank you so much for your help!

Dennis

# Answer
Welcome!

While a lot more information should be collected about your intended processes to set things up in the best way... my short answer would be "Yes, you will be able to accomplish this with civiCRM - but it's possible your solution may require some custom code for the report to look the way you want it to unless you're planning to use Drupal."

Without more information this is what I would start thinking about - it's possible that with more information, however, this is not the optimal solution :) ... only my fourth item mentions any custom code per-say:

* I would use relationships from Organization \<-\> Individual to define the Firm \<-\> Founder relationships. Both firms and founders can hold multiple relationships of the same type.
* Create a custom date field for Organization contact types "Date Founded" (or like)
* School needs more information and might be trickier but doable, sounds like it should be either a custom field for individuals (founders) or a custom activity type (visit school), based on your two sentences about it. Can one founder ever have multiple schools listed? Will you collect more information about schools (contact reference field) or just the name (plain text, maybe even a school-named group or tag depending on functions you need)? etc.
* I think your required 'report' as civicrm uses the term would require some custom code (many answers on this SE about how to go about that). You could probably generate this list using certain search techniques 'out of the box' but it would be slightly complex and depend on the level of comfort of your users. Using Drupal Views to generate this list may be an even easier way to go, if Drupal is a viable candidate for you.

Hope this is helpful!
> 1 votes

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


title: Event calendar for Civi 4.7.x?

text:
# Question
Title: Event calendar for Civi 4.7.x?
Related to this earlier question and this earlier question, I'm looking for a front-end event calendar. The most current extension I could find doesn't seem compatible beyond Civi 4.4, and we're running 4.7.16 ... on WordPress 4.7.2.

**Assuming others are running Civi 4.7 with some sort of working front-end event calendar, what's the most direct way to do this?**

# Answer
I'm not sure if it fits to your necessities but CiviEvent includes iCal for public events.

As you can see on CiviCRM user guide

> Select the Public Event box to include the event in promotional listings such as RSS feeds, iCal files or feeds, and event listing pages.

You can find more related information on how to use this functionality in this forum topic integration with iCal and/or Google Calendar - private calendars?
> 2 votes

---
Tags: civievent, extension, calendar
---


# Question
Title: How do I expose a civicrm profile to collect data from anonymous user (an application form) on a drupal node?
I have created a civicrm profile with the basic data I need. I have set all the fields to "public and listing," made them searchable. I have also set the form to add users to a group and to limit users to another group in listings. But now I am looking for the html code snippet so I can place the profile on a node in D7. I don't see anything but "Preview, Profile Create Mode, Profile Listings Mode,disable, Delete and Copy Profile" in the "more" link. Where is the html? I want this to be exposed to anonymous users so they can fill out and submit as an application form.

# Answer
On Drupal -\> how about simply use the URL - e.g.

```
civicrm/profile/create?reset=1&gid=30

```

and then add blocks with visibility settings show on civicrm/profile/create etc to dress up the page?

I would not recommend HTML code snippets - I do highly recommend webform\_civicrm! :-)
> 2 votes

# Answer
You shouldn't need to place it on a node. The link to Profile Create Mode would allow anonymous to create a contact record. If that is what you mean.

Being on Drupal, you can also consider using webform\_civicrm rather than civicrm Profiles
> 0 votes

---
Tags: civimember, profile, webform-civicrm
---


# Question
Title: Placeholders instead of labels in contribution forms
I created a Contribution page using Drupal webforms. For esthetics, I am only using placeholders and no field labels. I'd like to do the same for the Credit Card fields that are pulled in from Civi. Is there a simple way to use the field names as placeholders rather than field labels?

# Answer
> 1 votes
Ah - no there is not - those fields are grabbed from CiviCRM - as is :-(

So you can't edit them via the Webform tab; If I was heading this way I'd look at a drupal hook\_form\_alter

---
Tags: forms
---


# Question
Title: How to change the maximum number of members-by-relationship for given membership types?
I want to change the settings for the maximum allowable memberships by dint of the relationship with the primary member. I can easily modify this number in the membership type settings, but this doesn't reflect in the current memberships for any member - they continue to display the old limits.

Can I force this change into current memberships, do I have to wait until the membership is renewed, or am I stuck with the old settings?

# Answer
If you have access to the DB try changing the value in civicrm\_membership.max\_related
> 1 votes

# Answer
I bet you that if you hit Edit on the Relationship \[someone previously not inheriting the Membership\] - and then Save (without changing anything) - they now do inherit the Membership as you intended right?

So the Q is not just how do you change the maximum number of membership - but it's really about how do propagate that across.

You need to automate the trigger - I'm thinking an extension that essentially does an update Membership without updating the Membership.

Ok we can test that in the API explorer! /civicrm/api#explorer

I just tried this on one of my sites:

```
$result = civicrm_api3('Membership', 'create', array(
  'sequential' => 1,
  'membership_type_id' => "Fort Smith Kayak Club - Family",
  'contact_id' => 2,
));

```

Trying to update my own Individual Membership to a Family Membership - and that worked in that I inherited all my kids on this Family one.

Point is - updating the Membership via the API triggers a 'check to see how many should inherit'

So I recommend a small custom extension that loads Memberships and 'updates' them. That should work!
> 1 votes

---
Tags: civimember
---


# Question
Title: Why has entering a date changed in 4.7.16? Can it be reverted?
Entering a date has changed in 4.7.16 so the user can no longer drop down the year in order to select a year in the past. Now they have to scroll through months to go backwards! Imagine entering a date of birth of (say) 1967 - you have to go back 600 months!! I'm assuming this is a bug, but rather a serious one from a user's point of view. Does anyone know how this can be easily reverted to what it was before? In the meantime I'm avoiding my users....

I have raised problem CRM-20209

# Answer
There was an issue due to some refactoring around the handling of date fields to try to standardise them. This lead to a problem most notably in birth date fields in 4.7.16 but i'm guessing can be found elsewhere. This issue was raised CRM-19982

I suspect the same fix will most likely work for you. If you have a test site or would like to give a test a shot. I would recommend you look at the changes made to the files in the DAO directories here in the Pull Request and make the same changes on your server.

That pull has been merged into 4.7.17 which will be released i think in the next week or so
> 4 votes

---
Tags: 4.7, dates
---


# Question
Title: CiviCase tab not showing up on contact summary
When I open a case with a contact, the case tab does not show up on their contact summary. The case exists I can edit it through the case dashboard and it creates the correct relationships. I did a smarty debug and there's no tab info for case, so it's not just 'hiding'. I also tried on more than one contact, and more than one contact sub type, no dice.

Any ideas why the case tab doesn't populate? Or where I can go poking to figure it out.

(I'm running civic 4.6.4 on WP 4.4.4)

# Answer
> 1 votes
Check the display preferences (Admin \> Customize .. \> Display Prefs) and make sure for Viewing Contacts that Cases is selected

---
Tags: civicase
---


# Question
Title: Why might a dedupe rule fail to deliver results, or result in server crashing?
Title pretty much says it all and this question is being asked so it can be found easily and we can track progress in JIRA

# Answer
Having found the users have repeatedly misconfigured Dedupe / Matching Rules with a Weight Threshold of zero or NULL, both of which (I think) can result in a search of every record against every other record, I believe that Save should not be possible with zero/null.

Jira here
> 1 votes

---
Tags: duplicate-contacts
---


# Question
Title: what is a "unique open" in a mailing report?
Included in a mailings report is data on "unique opens" and "total opens". What is the difference between "unique opens" and "total opens"?

# Answer
> 2 votes
The difference is this, If someone opens an email immediately but then opens it again later on to read it again. CiviCRM will mostly likely track both opens. So in the Total Opens column stat that will = 2. However in terms of unique opens given that its the same person opening twice the unique opens = 1.

Hope that helps

---
Tags: civimail
---


# Question
Title: CiviCRM Webform - enforce ACL permissions
I'm building a webform to create activities against existing contacts. I want to make it so that the user completing this webform about an existing contact can only use it on contacts that are legitimately accessible to them via the ACL. Otherwise you get a message saying no and you can't fill in the form.

Obvs I could do this in a hook, but I bet it's functionality that other people would love.

So rather than fumble and hack around, I'm asking the community, where in webform\_civicrm would be the best place for this to go? Any other tips/advice/general suggestions?

Thanks,

# Answer
> 2 votes
Have you seen this extension:

https://civicrm.org/extensions/relationship-permissions-acls

It makes the permission flag on a relationship work like a true ACL.

But then perhaps you don't have relationships to work with?

So: \- create a relationship between your Primary Contact and the Contacts he/she has access to \[e.g. Counselor and the kids in the Youth Program\] \- via webform\_civicrm and the additional extension above you can pull in all a Counselor's Contacts on a webform -\> with enforce permissions true \- don't allow the Counselor to create new contacts - and lock a Contact's fields; that way the activity can only be created if the Counselor has the necessary permissions to view that contact.

To make the form not accessible to certain users who don't have the necessary permissions in CiviCRM (ACL) -\> put your ACL allow users into a CiviCRM Group -\> then use GroupRole Sync module to assign these users automatically to a Role when they login -\> then configure your form such that only users with that role are allowed to Submit the form.

---
Tags: webform-civicrm
---


# Question
Title: How to use Smart Groups with relative dates?
How can I setup a Smart Group to include members based on relative dates (e.g. last Activity)?

When I try to use relative date, e.g. *Yesterday* in advanced search, it correctly finds users with Activity on previous day, but when I create a **Smart Group** out of that search, it seems to fix the date in search criteria. As a result the next day smart group now contains members with Activity on the day **before** yesterday.

Neither running **Rebuild Smart Group Cache** (no parameters) nor clicking **Update Smart Group Counts** helped.

Am I missing something obvious?

Wordpress: 4.5.3 CiviCRM: 4.7.9

Tried to create a *Smart Group* in **CiviCRM Sandbox on Drupal** and it seems Activity Date gets fixed immediately when trying to create a *Smart Group* from *Advanced Search*.

# Answer
This was a bug in Core CiviCRM which is now fixed starting from version 4.7.14.
> 5 votes

---
Tags: smartgroups, dates
---


# Question
Title: Getting data automatically from CiviCRM to Google Spreadsheets?
Is there an easy (semi-)automatic way to get data from CiviCRM to Google Spreadsheets?

Data on CiviCRM side could come from search results (smart group) or a report.

On Google Spreadsheets side I would like to import data in specific document and replace particular sheet. Other sheets would then contain formulas to retrieve and process data from the imported sheet.

I would like the whole process to run it with a single click or even time-based (cron) to save time and eliminate human error in the process of exporting and re-importing regularly.

Has anyone seen or made anything similar?

# Answer
> 3 votes
You might want to check out this recording of a CiviCon session? https://www.youtube.com/watch?v=6K3awPdA7h0. Not sure if it will answer all your questions but I am sure it will give you a good idea :-)

---
Tags: export, google
---


# Question
Title: CiviVolunteer (2.1.2) doesn't show the opportunities in the frontend on Wordpress (4.6) with CiviCRM (4.7.10)
I was looking today and yesterday into installing CiviVolunteer on our CiviCRM installation (civicrm 4.7.10 on Wordpress 4.7) and when I try to navigate to the volunteer opportunities page from an event info page I only get a blank page with the header set to CiviVolunteer but no form loading.

There are no Javascript errors and all Wordpress roles have AjAX API as well as Register as Volunteer permissions.

You can see for yourself on a test instance at: https://piraten.lu/crm/civicrm/?page=CiviCRM&q=civicrm%2Fevent%2Finfo&reset=1&id=2

What could be the issue?

# Answer
> 1 votes
This did the trick for me: /civicrm/?page=CiviCRM&q=civicrm/vol/#/volunteer/opportunities

instead of: /civicrm/vol/#/volunteer/opportunities

# Answer
> 0 votes
Do you have the Angular Profiles extension installed and enabled? It's a prerequisite for CiviVolunteer.

# Answer
> 0 votes
Looks ok to me pal (FireFox). (I'm scheduled to volunteer shortly).

---
Tags: wordpress, civivolunteer, 4.7.10
---


# Question
Title: Enabling CiviVolunteer 2.0 Volunteer Opportunity Listing
How do I enable the public listing of volunteer opportunities for visitors to my civicrm website?

# Answer
> 3 votes
There's a link under the Volunteer menu "Search for Volunteer Opportunities" that you can copy to a menu option or a button:

http://address-to-your-site/civicrm/vol/#/volunteer/opportunities

You also need to make sure that the permission "CiviVolunteer: register to volunteer" is granted for the Anonymous role if they're not going to be logged in (or another role if they are).

There's some additional information at http://civicrm.github.io/org.civicrm.volunteer/docs/

Note that Angular Profiles should be installed an an extension in the CiviCRM extensions directory and then enabled.

# Answer
> 3 votes
The page for searching for opportunities is as Joe and Dan said: http://address-to-your-site/civicrm/vol/#/volunteer/opportunities

And I can confirm that Access AJAX API is a required permission. The new interface is built on Angular, and there is no way around allowing ajax permissions. See: https://github.com/civicrm/org.civicrm.volunteer#self-service-volunteer-signup

I've consulted with the core team and there is no known security threat to allowing anonymous users to access the Ajax API.

# Answer
> 2 votes
So I was having the same problem and could not find a valid reference. In Drupal permissions, I extended this to anonymous user:

```
CiviCRM: access AJAX API
Allow API access even if Access CiviCRM is not granted

```

Can anyone else confirm that this is the appropriate fix? It works for me but I'm wondering if there are any negatives to enabling AJAX API access to anon...

# Answer
> 1 votes
If your wordpress install will not show volunteer opportunities, i'd like to share that this did the trick for me:

/civicrm/?page=CiviCRM&q=civicrm/vol/#/volunteer/opportunities

instead of: /civicrm/vol/#/volunteer/opportunities

---
Tags: civivolunteer
---


# Question
Title: Is something missing in Activity search?
In **Advanced search** I see the radio buttons *With*, *Assigned to* and *Added by*. However there is no option to enter any person's name.

Is there something missing on interface level in Activities section of Advanced search?

CiviCRM 4.7.14. on Drupal (it looks the same in sandbox).

# Answer
> 1 votes
Since you are using Advanced Search, there is a whole section at the top called Basic Criteria, which has fields like Name.

On dmaster I double checked. I ran the search with just 'with, and got 92 results, i then ran the search with "d%" in the Name and it dropped to 37 Results.

Is that what you needed to know, or have i entirely missed your point?

---
Tags: activities, search
---


# Question
Title: I need to export or copy CiviCRM structures such as membership types, contribution pages and price sets to another website (Joomla)
I am rebuilding a Joomla website with a corrupt database. I would like to recreate the CiviCRM structures in the new website. That would include membership types, price sets and contribution pages.

# Answer
> 1 votes
There are a few approaches, none perfect. It would be great to be able to export config of entities and load that into another site / instance.

1. It's possible to write code to generate the various entities using the CiviCRM API. This can work, but probably has higher up-front time costs than option 4 below. It's what I'd most likely do if I wanted to be able to test the deployment of changes and had a medium-scale budget.
2. CiviCRM offers a hook (`hook_civicrm_managed()`) which you could use to configure your site with the various entities mentioned. This has some challenges, eg it "locks" the managed entities to the extension in question - disabling that extension in future might then remove the managed membership type, potentially affecting recorded memberships and so forth. (I'm not sure whether editing managed entities is permitted, either?)
3. It's possible to export the SQL entries which relate to the specific values you want, but you'd need to match up the IDs for the entities (memberships, contribution pages, price sets and options etc) on loading. Kinda ugly.
4. You can click your way through the config. I'd guess you're asking this because you think there should be a more reliable way to deploy configuration ... as of today, I don't think there is. This is your low budget option.

One important factor is that these entities may need to be created in a specific order to handle dependency, since the priceset / options may relate to the membership type, and that membership type may relate to an organisation contact, and ...

This is a question which has been asked before, but IMO hasn't as yet been solved well. These previous SE questions might offer some insight?

---
Tags: export
---


# Question
Title: How do I write unit tests that verify a hook is being fired?
I found this example but it doesn't look like it would generalise to all hooks.

The use case is for API4 \- basically whenever any action is called I think we should be able to verify that particular hooks (and only those hooks) are called.

# Answer
> 2 votes
So I figured this out. The specific hook engine for unit testing, very conveniently, comes with an injectable mock property.

After grabbing the hook engine with `$this->hookClass = \CRM_Utils_Hook::singleton()` you just need to inject a mock object that has a magic `__call()` method with somthing like:

`$this->hookClass->setMock($this);`

The hook engine will then call your `__call($name, $arguments)` method with every hook invocation.

You can see a fuller example here (please ignore the reporting stuff going on - I doubt that is best practice! Also the use of the unit test class as the mock is a bit lazy - its probably best to make a new class to provide the mock)

---
Tags: hooks, unit-testing, phpunit
---


# Question
Title: Drupal views recipe for displaying Civievent Participants using a jump menu selector
I managed to do this once before, but can not remember how to do it again. I'm still new to all this.

I need to display a list of participants for all active events using Drupal Views with a Jump Menu selector.

I have managed to create a view showing a table of current participants grouped by event title. But now I need another Views page that shows a jump menu containing the name of the event and and the number of attendees. When I select an event and push the go button, a table showing the names of the attendees for that event are displayed.

Any help would be appreciated.

# Answer
Add an Exposed Filter in your view -\> and if you also have Better Exposed Filter module installed - then you have some more configuration options like bypassing the Apply button.
> 1 votes

# Answer
There was an explanation using JumpMenu on Stack Exchange here but you need to sign up to see it.

Quoting mattwire

> google was eventually my friend. It works by creating a view as a block setup as a jump menu (select list) which you setup to filter on all the valid records. You set the output of the field to rewrite as a path which matches the path of the second view which has a contextual filter setup to use the parameter passed in via the path. Using a jump menu and contextual filters gets me what I want with two views
> 1 votes

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


# Question
Title: Views integration - Missing handler for custom fields on relationships broken since upgrade to 4.7.15
I have a report in views that pulls data from custom fields on a relationship between two contacts.

Since an upgrade to 4.7.15 It is no longer displaying that data and on opening the view I see that the fields have the notice "missing handler"

I've cleared caches and ensured that the Drupal database is fully updated and so on.

Could this may be another symptom of: CRM-19545. PR-417

Can anyone shed light or suggests steps to resolve?

# Answer
Just ran into the issue when upgrading from 4.7.13 to 4.7.16. Spent way too much time trying to figure it out and far too many views data cache clears/drush cc all.

In case anyone runs across this having the same problem, this is a direct link to the revert patch mentioned above: CRM-19545: Revert CRM-18776 to get back missing custom fields
> 2 votes

---
Tags: drupal-views
---


# Question
Title: Custom Email Greeting token doesn't work
I've done a custom email greetings that have this structure:

```
{capture assign=l}{contact.preferred_language}{/capture}
{capture assign=g}{contact.gender}{/capture}
{if $l=="en_US"}Dear
{elseif $l=="et_EE"}Kallis
{elseif $g=="Female"}Дорогая
{else}Дорогой{/if}
```

It works fine in the summary tab of the contact profile. But token `{contact.email_greeting}` doesn't work when I am sending emails. There is nothing instead of email greeting.

Do you have any suggestions how can I fix this problem?

Thanks in advance.

# Answer
> 4 votes
Any chance you don't have smarty enabled for civiMail so your capture-assigns and ifs aren't working in the mail?

Try checking your civicrm.settings.php file and look for the line

```
define( 'CIVICRM_MAIL_SMARTY', 1 );

```

as per https://backofficethinking.com/blog/tip-how-personalize-emails-civicrm. If you don't find it, or if it's set to 0, you'll need to add/change it for this to work.

---
Tags: wordpress, email, tokens, smarty
---


# Question
Title: How to remove contacts without affecting events attendance data
Is there a safe way to remove/delete/deactivate CiviCRM contacts who have attended events, without affecting the events attendance data?

# Answer
> 1 votes
First of all: there is NO way in which you can delete contacts without affecting events attendance data.

I would try in a test environment to trash CiviCRM contacts that have attended events and check if you still see what you want to see. (And also it will help if you explain what you mean by attendance data)

# Answer
> 1 votes
It might depend on how you need your 'attendance data' stored. Eg after each event you could enter a 'count' of your participants in to one of more custom fields on the Event, eg one for 'attended', one for no show, etc.

That way the 'data' is stored on the event, you can always see how many folk attended, but you can delete the Contacts. Downside of course is that you would then also need some home made reporting on this but that doesn't seem tricky.

---
Tags: civievent
---


# Question
Title: Logged out periodically for unknown reason and word replacement not working
On one of the CiviCRM sites I've set up, it keeps logging me out every 30 minutes or so. I have set the cookies in the default.settings.php file so that I'm logged out when I close the browser but it's exactly the same as my other sites, where there's no problem. Same hosting as well. Any ideas why it's throwing me out all the time??

I'm on Drupal 7.53 and CiviCRM 4.7.16.

EDIT: This is still ongoing, I've restored all settings across the site that I can think of that may trigger an issue. Just today, I've had the following error message (usually it just logs you out with no warning) but I thought it may throw some light on the issue?

And this is my cookie session settings in the default.settings.php file:

----- THE FOLLOWING ISSUE HAS BEEN RESOLVED SO CAN BE IGNORED -------

Also, same site, different issue. I've done word replacement and changed the name from Organization to Organisation but when I search for Contact Type, it's still showing Organization - regardless of whether I specify exact match or not for the word replacement?

# Answer
Check to see if Drupal module automated logout is installed. I would recommmend it instead of what you're doing with cookie settings - you can specify to logout after x minutes of inactivity and set that x per role.

Yes word replacement indeed does not work to override 'organization' -\> what you need to do is use locale language setting (settings localization) instead.
> 0 votes

# Answer
I've solved the problem with the name change:

* I used the word replacements function.
* When you check 'Administer \> Contact Types' it looks like the 3rd Contact Type has changed...
* BUT you still need to 'Edit' and specifically change it
> 1 votes

---
Tags: drupal, contacts, php
---


# Question
Title: Civi dashboard and menus won't display after install
I'm attempting to get an instance of Civi up and running on a WordPress site. The install says it goes fine, but when I try to enter the dashboard, I get this:

I did a test install of WP and civi on a different site using the same host and got no problems. I checked the PHP settings against each other and they are the same.

The `System Status: Error` link takes me no where, nor does the `Configure Your Dashboard` link. By which I mean the URLs they give are just

* `http://mydomain.website/civitest2/wp-admin/admin.php?page=CiviCRM#`
* `http://mydomain.website/civitest2/wp-admin/admin.php?page=CiviCRM&q=civicrm/a/#/status`

When I click on them, the page just loads for a while and I'm taken to this screen:

**Update**:

I've tried visiting civi features by inputing the URLs directly, for example `?page=CiviCRM&q=civicrm%2Fadmin%2Fconfigtask&reset=1` to reach the configuration checklist. I suppose the problem then is that the CiviCRM Dashboard and Toolbar do not show up when I try to access Civi. Another interesting thing is that Civi's CSS does not render when I'm in the backend. The image below is my contact group manager:

**Update 2**: As requested I checked he JS Console and hoo boy are there a lot of errors! 64 in all. Mainly 404 errors. For instance, `jquery.min.js` fails to load because the server responded with 404. It's the same story for most of them. Nearly all of the errors are 404s, but there are a few that read `Uncaught TypeError` which I'll reproduce here:

```
Uncaught TypeError: Cannot read property '_defaults' of undefined
    at admin.php:8
    at admin.php:102
Uncaught TypeError: $ is not a function
    at admin.php:7
    at admin.php:146
Uncaught TypeError: CRM.$ is not a function
    at admin.php:517

```

For all the 404 errors can navigate to that in my file in FTP and look at it, but cannot access them through my browser, which is something I can do on installs that work. For example `/wp-content/plugins/civicrm/civicrm/bower_components/font-awesome/css/font-awesome.min.css` is present in my files, but I can't navigate to it in browser.

Looking at the permissions to get to that file, every directory is `755` and the resource itself is `644`.

### Update

I checked `settings.civicrm.config` and found the global variable `$civicrm_root` was set correctly to `/home/USER/public_html/civitest2/wp-content/plugins/civicrm/civicrm/`. I went to the Resource URLs settings page and replaced the CiviCRM Resource URL which was defaulted to `[civicrm.root]/` with `http://mydomain.website/civitest2/wp-content/plugins/civicrm/civicrm/`. On refresh, the menu and dashboard were there.

This could have been discovered faster had I bothered to read the URLs more intently and see that it was duplicating my domain root.

# Answer
From what you describe, there are some javascript issues in your page, possibly because the URL of some required resources is misconfigured.

I'd inspect the URLs related to errors like the 404 for jquery.min.js you report, and compare those URLs with the actual locations on disk of the same files.

This can happen many ways -

* CiviCRM was incompletely uploaded, or
* CiviCRM is configured to request files at an incorrect path (see note below), or
* CRM-17633: WordPress in its own directory breaks CiviCRM, or
* the file is somehow named `jQuErY.mIn.Js`, or
* permissions don't allow you to access some resources (as JohnFF suggested), or
* some .htaccess or nginx or apache config prevents access, or
* ... something ...

### "CiviCRM is configured to request files at an incorrect path"

As of 4.7, Civi needs configuration in *two* places to get things working right! To check this, verify both the CIVICRM\_BASEURL setting in `civicrm.settings.php` and the resource URLs in CiviCRM UI at Administer ➡ System Settings ➡ Resource URLs (`wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin%2Fsetting%2Furl&reset=1`).

If the files are at the correct URL but inaccessible, your webserver error logs should show information on why the webserver doesn't want to serve that file to your browser.

Hope that helps :)
> 3 votes

# Answer
To further expand on Chris' Answer I'll add one last thiught.

If WP is installed in it's own directory as detailed here: https://codex.wordpress.org/Giving\_WordPress\_Its\_Own\_Directory CiviCRM will not 'just work' Custom settings will be needed.

The best way to tell if WP is in it's own directory is if the public url is https://example.org but the url to wp-admin is https://example.org/subdirname/wp-admin

If that is the case, this wiki page details where we are on the process of getting CiviCRM to work with this setup and some custom configurations that you can try - https://wiki.civicrm.org/confluence/display/CRM/WordPress+installed+in+its+own+directory+issues
> 1 votes

# Answer
Time to check out permission settings! 644 for files and 755 for directories. Also, check the .htaccess files, those sometimes get missed during copies.
> 0 votes

---
Tags: installation
---


# Question
Title: Can CiviContribute and CiviGrant work together?
I'm part of a non-profit that takes in donations from corporations, and runs an internship program twice a year. We usually have around 15-20 different organizations offering internships. Our donors can specify whether they want their funds to go a specific organization participating in this internship round, earmark it for a project in future rounds, or put it in the general fund. Often, part of the donation goes towards into a travel fund which is allocated from later.

It sounds like we want to use CiviGrant to track what part of our budget is allocated to specific project internships, and perhaps use it to track our travel expense requests. We also need to track the invoicing status for our donors, which sounds like we need CiviContribute.

Can the two modules work together? For example, could I record a promised donation from company X that is earmarked for project Y and Z?

We also need to get a sense for how much money we have left in the general fund for improvement projects once we fulfill our grants and receive all our outstanding invoices. Is there an easy way to create a report or something similar combining data from CiviGrant and CiviContribute?

# Answer
You may be able to get what you want by using a Campaign for each 'donation' and then you can mark other entities with that.

Also worth noting that if CiviGrant doesn't quite match your use case, other users have switched to just using Activities, or CiviCase to create their own custom 'grant' workflow.
> 1 votes

---
Tags: civicontribute, civigrant
---


# Question
Title: Why do some From addresses work and others get rejected
I'm having some strange problems with sending out emails.

I've run a number of tests using different From addresses, and some of them work fine, but others are rejected by the recipient mail server. Here are the results of 9 different From addresses:

Fail:

xxx\_xxxxxxx@hotmail.co.uk

xxx\_xx@hotmail.com

xxxx\_xxxxx@yahoo.co.uk

xxxxxxxxxxxxx@yahoo.co.uk

Succeeds:

xxxxxxxxxxxxxxxx@gmail.com

xxx.xxxxxx.xxxxxx@me.com

xxxxx.xxxxxxxxx@talk21.com

xxxxx@xxxxxx.org.uk (same domain as site)

xxxxxxxxxxxx@xxxxxx.org.uk (same domain as site)

xxxxxxxxxxxx@djinter.net

They don't fail for all recipients - there are clear patterns about which succeed and which get rejected. Most of the main webmail services: gmail, yahoo, hotmail, etc are rejecting them. Lesser know mail servers (presumably with less stringent criteria) are accepting them.

Outbound Mail is set to mail().

Any one else had problems like this, or able to offer advice?

# Answer
> 8 votes
In general: you should NOT use a from address of a domain you do not control.

the smtp protocol does not care and you can send an email pretending to be whomever sender you want, but given how it has been abused by spamers, other protection layers were put in place (DKIM, SPF).

These basically white-list which servers are allowed to send emails on the behalf of a specific sender (domain). Each other server in the world can then look at these lists, and decide to accept or reject your email based on that.

So it's not a hard rule, and depending on what from email you put and to whom you send it and how the various email servers are setup, it will work... or won't.

And no matter what, it's likely that more and more domains will white-list what are the servers allowed to send on their behalf, and more and more mail servers will look at these list and reject "unauthorised" senders.

So consider an anomaly that you can still send as @me.com for instance, and that it will soon fail.

Use your own domain(s) for the from and do set up the needed dns records to white-list your civicrm server (and the other servers you use to send emails).

And yes, it's a bit of a pain to set up, I'd suggest you to use an external provider (sendgrid, mailjet...) to deal with that. they all have clear instructions on how to set it up.

---
Tags: drupal, civimail
---


# Question
Title: How do I change the address on system workflow messages?
Hi "I need to change the address that is sent out on our invoices. These are in the system workflow messages and although I didn't write the code for them, I believe they may have been written in as domain address. How do I update that address please?

# Answer
> 2 votes
As far as I know:

Your default organization address can be found in Administer/Communication/Organization Address and Contact Info. That should be your $domain.address.

You can also update the sytem template Contribution Invoice Receipt and replace the default domain address with your desired address settings if you for whatever reason do not want to update your domain address.

---
Tags: addresses
---


title: CiviMail space characters added

text:
# Question
Title: CiviMail space characters added
In CiviMail, in the subject or at the end of the text of the mail, spaces are added after certain number of characters.

How to solve that?

Screenshots of the problem below. An additional space between word European and agricultural.

# Answer
> 2 votes
We did enounter the same issue earlier. I created an issue for it and proposed a patch: https://issues.civicrm.org/jira/browse/CRM-20228

---
Tags: civimail
---


# Question
Title: Gift Aid Declarations with overlapping dates
I work in the IT department, CiviCrm isn't my forté. I have been tasked with helping the marketing department with a few issues with Civi.

One issue that I keep scratching my head about is Gift Aid Declaration. When I try to edit a declaration / add a new one, it won't allow me to submit the form as dates overlap.

> x Start Date This declaration overlaps with the one from 11/05/2013 to 07/22/2014
>
> x Start Date This declaration overlaps with the one from 12/31/1999 to 07/23/2014

Is there a setting I can change via Custom fields to allow dates to overlap?

# Answer
The short answer is 'No' there aren't any settings to allow this. Gift Aid declarations don't have to have an end date, when you sign up to Gift Aid to an organisation you can effectively sign up for ever (unless you specify an end date). Bearing this mind, I suggest that you change the end date of the previous declaration to avoid the overlap.
> 3 votes

---
Tags: civicontribute, dates, gift-aid-extension
---


title: Problem connecting to payment processor

text:
# Question
Title: Problem connecting to payment processor
The CiviCRM (4.7.14) membership sign-up page for our website will not always connect to Paypal (standard), our payment processor. Sometimes it works, mostly not. In Firefox, the error message is: "The page isn’t redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies." I have checked settings in CiviCRM and with Paypal, and everything looks OK as far as I can tell. Looking for help to get this issue fixed.

Our site is on Joomla 2.5.20 and appears to be up to date. To the best of my knowledge, the connect to Paypal worked fine until about 6 months ago. Since then, CiviCRM was updated to 4.7.14. The problem is not unique to Firefox; complaints also come from people using Edge, Chrome, Safari in different countries all around the world. Doesn't seem to be a difference for a logged-in user or non-logged-in visitor.

# Answer
> 1 votes
This seems like it might be your CiviCRM not having a single canonical URL.

CiviCRM form processing requires a canonical URL to be set. If your site is configured to use `http://example.org` and the visitor lands on `http://www.example.org`, CiviCRM's form processing will redirect them to the configured base URL part way through the contribution flow and fail (because the user's cookies no longer are supplied).

I can't load the URL you've linked to, but if I start the Join process at the first URL below, I am able to get to PayPal. If I start at the second URL below, I see the "too many redirects" notice you describe.

* `http://isebiogeochemistry.com/index.php/iseb-membership`
* `http://www.isebiogeochemistry.com/index.php/iseb-membership`

Finding your site via Google ("ise biogeo chemistry") leads me to the latter hostname.

To prevent this (mis) behaviour, both the protocol (http vs https) and the hostname (example.org vs www.example.org) must be consistent (ideally, enforced with a redirect from ANY wrong URL to the single "correct" one).

How to configure canonical URLs varies between webserver and CMS, so I won't document that here. You'll find plenty of good existing docs with a search for eg "(your CMS) + canonical URL plugin", or "(your webserver) canonical URL".

Some similar questions on CiviCRM Stack Exchange:

---
Tags: civimember, payment-processor, paypal
---


title: CiviMail click through inflation

text:
# Question
Title: CiviMail click through inflation
I investigated our web logs because one of our organizations reported what seemed like strangely inflated click through numbers, including a lot of click throughs reported the very minute the message was sent.

The web logs confirmed the statistics that CiviCRM had in the mailing report.

However, I noticed that many of the IP addresses looked like they were coming from the same block. A whois search revealed that they were all IP addresses that belonged to the Anti-virus vendor Barracuda.

I can't be 100% sure, but it looks to me like many of the recipients may be using Barracuda software, which may be automatically reading the messages and then "clicking" through all links in the messages to ensure they don't go to any phishing sites.

If this theory is correct, then we may be saying good bye to click throughs as a useful metric, which is a shame since "opens" are also pretty worthless (although barracuda does not seem to be downloading the open img).

Any suggestions on how to avoid this problem? We could exclude barracuda IP addresses but that seems like a losing battle if this approach becomes widespread.

# Answer
> 3 votes
This is a problem, and your analysis seems to be correct

As this article suggest, another (more robust) option would be to track who clicks on all links, including hidden ones, and automatically remove the clicks from this user.

https://wordtothewise.com/2013/07/barracuda-filters-clicking-all-links/

X+

# Answer
> 1 votes
One approach might be to write an extension which observes the "open" request and intercepts writing to the CiviMail open tracking table if it identifies the origin as being one of those source IPs you've identified.

Since malware / phishing authors can (will!) undertake a similar tactic to evade detection, I'd expect Barracuda to modify their source IPs to evade detection by malware authors ... This might not be a good battle to get caught in!

---
Tags: civimail, click-through
---


title: Mailmerge token syntax

text:
# Question
Title: Mailmerge token syntax
Please could someone tell me what is wrong with the following Dear contact.nickname Thank you. I know that brackets need to be used.

# Answer
> 1 votes
Yes you need brackets: the curly { } kind

When composing a mail mesage - hit the Insert token button on the right - select the one you want - and it will insert it in the text (where your cursor was located) - including the { }

# Answer
> 1 votes
Note that nickname is an optional field for each contact.

If you use "Dear {contact.nick\_name}," then contacts who do not have a nickname defined will end up with "Dear ,".

I suggest using {contact.first\_name} instead.

If you really want to use nicknames, you could create hooks to define a new token, e.g. contact.nick\_or\_first\_name, and populate it with nickname if it is not null, or else first name.

# Answer
> 1 votes
If you are on a screen that offers 'tokens' in top right, eg on 'send email' or 'new mailing' etc then you can just type in 'nick' and it will offer you the relevant token(s) and then you will get the spelling correct automatically.

# Answer
> 1 votes
I used a custom token (based on Coleman's blog post) to look and see if there is a nickname. If not it will default to first name.

https://civicrm.org/blog/colemanw/create-your-own-tokens-for-fun-and-profit

So I can use the nick\_name token without worry it would be a blank field.

---
Tags: mailing
---


# Question
Title: HELP! civiCRM Administration Area Not Showing! [Joomla 3.6.5] [civicrm 4.7.16]
I'm using CiviCRM version 4.7.17 on Joomla version 3.65. I changed my civicrm resource URL hoping it would load the civicrm.css file but instead I can no longer access my administration area. Please see phone of what I am receiving when I try to access the civiCRM component. How do I get back to the system settings area so I can change it back?

# Answer
> 1 votes
You could try to go the page directly

www.yoursite.org/administrator/?option=com\_civicrm&task=civicrm/admin/setting/url&reset=1

If you have sql access you could change them back. They are stored in civicrm\_settings

```
SELECT name, value FROM civicrm_setting WHERE group_name = "URL Preferences"

```

You'll see the url between quotes in the value field.

---
Tags: admin
---


# Question
Title: Do I need to sanitize quickform inputs in a extension?
Hopefully this is a quick one. I'm creating a form in an extension. Regular QuickForm - nothing special. Do I need to sanitize the inputs before processing them? Or does Civi/QuickForm handle that?

# Answer
> 1 votes
How are you saving the data? If you are using the api, then no there is no need to sanitize it, the api already guards against sql injection.

---
Tags: quickform
---


# Question
Title: How to set default for 'Unsubscribe Group' in civimail
* Do a search using 'Find Contacts'
* Select a few and choose task 'Email - schedule/send via CiviMail'
* How do I set default value for *Unsubscribe Group*?

Any help is much appreciated.

# Answer
There is no way through the UI that I am aware of.
> 1 votes

---
Tags: civimail, angular
---


# Question
Title: hook civicrm_post not triggering as expected (Joomla)
I have set up a hook to assign a group to new contacts when they are created. I have set it up the old-fashioned way, ie with a function called joomla\_civicrm\_post in a file called civicrmHooks.php in the php override directory. But the function is called every time the master cron job fires, whereas I expected/wanted it to be called when a new contact is created. Have I missed something obvious? Should this work? Or do I have to implement the hook as a Joomla plugin in order to get it to trigger correctly? Thanks.

Joomla 3.6.5, CiviCRM 4.7.16, php 5.6.30

# Answer
> 0 votes
OK, it was my stupid fault. The function isn't only called when a contact is created - it's called when any event happens (eg cron job). So the important line is the conditional statement (which should be the first line of the function) which decides whether the function should continue. In my case, this conditional line was:

IF ( ($objectName != 'Individual' && $objectName != 'Organization') || $op != 'create') { return; }

---
Tags: hooks, cron
---


title: How to undo a deleted report

text:
# Question
Title: How to undo a deleted report
I created a report to log in our donations however this morning when I deleted a batch it has deleted the entire report template and I now have empty contribution batches with just the amounts and not the donors information.

I urgently need this restored as we have used this report for logging in all our donations.

Please can someone help me asap.

Many thanks,

Grace

# Answer
1. Look in Search \>Advanced Search
2. Put in Search parameters that would show the lost donor data
3. Down in the bottom right-hand corner of the Search Criteria box check Search in Trash
4. You should be able to check all and then under actions restore.
> 1 votes

---
Tags: reports
---


# Question
Title: Default registration status for on-line registrations
We are trying to use CiviCRM for a registration process that has multiple levels of behind the scenes checks required which we were hoping to track by additional types of 'Registration Status' but seem to have hit a buffer in that there doesn't appear to be any way to specify the starting status for an on-line registration; am I correct in thinking you can't change this somewhere from "Registered" to something else?

We looked at the 'participant approval' option but found the full logic of that doesn't quite work for us as we need information from the corresponding price set at the point of initial submission rather than after the completion of the approval.

# Answer
> 1 votes
I believe you're correct that the default participant status can't be changed when using the standard event registration process. See discussion at Default participant status doesn't recognize 'order' value of status.

---
Tags: civievent, registration
---


# Question
Title: Some successful Paypal transactions are showing "Pending (incomplete transaction)"
Some of my event transactions are showing "Pending (incomplete transaction)" when they have been successfully processed through Paypal. Not all of them just two since my event went live. I'm on Joomla! 3.6.5 and CiviCRM 4.7.16

# Answer
> 1 votes
We had trouble with this, it could be related to your IPN listener in paypal, (Log on to paypal, go to profile, my selling prefs, Instant payment notifications to check out what's going on - if it looks fine, send paypal a message)

Or you should certainly double check that you've got the correct paypal account details saved within the Payment Processor in Civi.

We had loads of trouble figuring out why our payments were not completing, and in the end it boiled down to which paypal email address was being referenced in the payment processor - the default email on paypal had been changed.

---
Tags: paypal, pending
---


# Question
Title: How to Deal With Email Only Contact Records
Does anyone have advice for how to run several mailing lists via Civicrm such that 'email only' contact records don't pollute the various search/reports/etc view?

We've been debating moving our old lists to what is otherwise a great Civi/Drupal combination, but have been hesitant since many thousands of the contact records would be imported with only an email address. Unless I am missing a setting or something obvious, having these records would make things a tad awkward for users when navigating through various contact interfaces.

Is there any way to set a default 'exclude email only' contact records or similar system wide setting?

# Answer
I'm not sure you'll find the email only contacts will really be noticed with day to day operations. We have some, granted less then 5%, and I rarely come across them.

Think about the kind of queries your users do with contacts, like using the quick search box in the upper left hand corner and what situations they would likely pull up a bunch of email only contacts. You have to be searching for a name or email that matches an email only contact's email. (When it does, I often find a matching contact. The contact is fully in civi but they gave a different email address when getting on an email list.)

I don't think there is a way to by default exclude them. However, there are a number of ways you can make it easier to isolate them in queries.

1. You can create a smart group of everyone else. (query builder, individual, last name not null). Then use that group for queries.
2. You could usurp one of the privacy options if you aren't using it, like "Do not Phone" or "Do not trade" or "Do Not SMS" and exclude that option in advance query.
3. You could create a new contact type for the email only; though, since it will be a child of individual, there might not be too useful.
> 1 votes

---
Tags: contacts, email, mailing
---


# Question
Title: Which contact record should house the membership?
My question is related to how drupal users interact with their civicrm membership and contact record.

In 2013 we moved to using CiviCRM. We already had 'Group' and 'Household' membership types, so it was assumed that the Civi membership would be housed on Organisation and Household contact records, and the membership inherited by related Individual records.

However in the following years I've been wondering if we got that wrong, as there are several reasons why this doesn't work:

1) Drupal users can only be associated with an individual contact record, so they would not be able to renew a membership online if it is housed on a Household or Organisation record; they would probably end up creating a brand new membership but on their Individual record.

2) The CiviContribute pages allow for a user to join on behalf of an organisation, but when this takes place the membership is by default added to the individual's record - the relationship of 'employed by' is created by default to link to the Organisation record (which only gives inheritance to that record if the relationship for that membership is set up using that relationship.)

3) If a membership housed on an individual record is renewed online, the membership inheritance does not seem to renew the membership on the Organisation record, but at least the individual still has an active membership and therefore able to use and drupal related benefits associated with current membership.

So I am not sure how CiviCRM is actually meant to be used in this scenario - should we actually house the membership on an individual record by default and allow access via Webform to allow them to create their related Household or Organisation contact records?

Please let me know if you need any more details!

# Answer
Drupal users can (should) only be associated with an individual contact record but with a correctly set up 'on behalf of' workflow this can allow for an Individual to purchase a membership on behalf of an organisation. (I say 'should' because I know users have overridden this and hence permitted the Drupal user to have a uf\_match link to the Org record)

Provided they get a Permissions 'current employer of' relationship, they should then be able to return to a renewal page and have the option of renewing on behalf of the original organisation (or any other organisations they have permissioned current employer relationship with), or join on behalf of a new one.

Inheriting of memberships does not need to be set on the Employer of relationship if you don't want that, eg you could use a Primary Contact for relationship so that only specified individuals 'inherit'. This can help when it comes to sending out reminders.

In terms of Households, we have mostly shied away from using that concept altogether since it does not work with 'on behalf of'. I suspect it is not much work to make this possible, and have flagged it in the past, but no one has funded it, and we have always preferred our work arounds of either having sub-Organisation types, or using Webforms to manage the relationships.

The whole 'on behalf of' can be tricky to get right but there won't be one magic solution that meets all needs.
> 3 votes

---
Tags: civimember, households
---


# Question
Title: Why does this use of the API for Events work in the Explorer, but not in the Message Template?
I'm trying to use the CiviCRM API to show a list of upcoming events (in the confirmation email a user receives when they sign up for an event).

When I try the operation in the API Explorer it appears to return exactly what I want, but when I apply the code (in this case, the Smarty code) in the Message Template, the filtering to only show events after the date specified doesn't seem to take any effect. It just shows all the events.

```
{php}
  $this->assign("param_start_date", array('>' => "2013-10-22 18:00:00"));
  $this->assign("param_options", array('sort' => "start_date"));
{/php}
{crmAPI var='result' entity='Event' action='get' return="title,start_date" start_date=$param_start_date options=$param_options}
{foreach from=$result.values item=event}
  {$event.event_title}
{/foreach}

```

I got the above code using the API Explorer by:

* Selecting 'Event' as the entity.
* 'Get' as the method. 'Event Title' and 'Event Start Date' as the Fields to return.
* 'Event Start Date' as the parameter, with '\>' as the operator and '2013-10-22 18:00:00' as the value.
* Selecting 'Sort' as an option, with value 'start\_date'.

# Answer
That's really strange! Just a guess but maybe it's a problem with the way `$this->assign` works in message templates? I've only tested that construct in smarty *pages* and message templates might have a different way of processing variables like that.
> 0 votes

---
Tags: civievent, api
---


title: Cannot save civivolunteer project

text:
# Question
Title: Cannot save civivolunteer project
I have CiviVolunteer installed on WordPress and have been using it without any issues until this morning when each attempt to save a project led to the following error message: 'A technical problem has occurred Your submission was not saved. Resubmitting the form is unlikely to resolve this problem. Please contact a system administrator.'

# Answer
> 1 votes
I had the same issue. After enabling debugging I saw that the civicrm\_volunteer\_project table was missing the title field.

There is an alter query in this file that did not run correctly for me as it failed on removing the foreign key.

`extensions/org.civicrm.volunteer/sql/volunteer_upgrade_2.0.sql`

Modified version (though you should run your own tests):

`ALTER TABLE`civicrm\_volunteer\_project`ADD`title`VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL
 COMMENT 'The title of the Volunteer Project'
 AFTER`id`,
ADD`description`TEXT COLLATE utf8_unicode_ci
 COMMENT 'Full description of the Volunteer Project. Text and HTML allowed. Displayed on sign-up screens.'
 AFTER`title`,
ADD`loc\_block\_id`INT(10) unsigned DEFAULT NULL
 COMMENT 'FK to Location Block ID'
 AFTER`is\_active`,
ADD CONSTRAINT`FK\_civicrm\_volunteer\_project\_loc\_block\_id`FOREIGN KEY (`loc\_block\_id`)
 REFERENCES`civicrm\_loc\_block`(`id`)
 ON DELETE SET NULL,
ADD`campaign\_id`INT(10) unsigned DEFAULT NULL
 COMMENT 'The campaign associated with this Volunteer Project.'
 AFTER`loc\_block\_id`,
ADD CONSTRAINT`FK\_civicrm\_volunteer\_project\_campaign\_id`FOREIGN KEY (`campaign\_id`)
 REFERENCES`civicrm\_campaign`(`id`)
 ON DELETE SET NULL,
MODIFY`entity\_table`varchar(64) NULL,
MODIFY`entity\_id`int(10) NULL;`

---
Tags: civivolunteer
---


# Question
Title: How to control API4 permissions for CRUD operations?
How do I control permissions for API4 calls?

# Answer
> 5 votes
# Events

The API kernel broadcasts an authorise event.

## Core permission check listener

The main API permission check subscriber will respond to the event by:

```
$apiRequest = $event->getApiRequest();
if ($apiRequest['version'] < 4) { /* blah */ }
elseif ($apiRequest['version'] == 4) {
  if (!$apiRequest->getCheckPermissions()) {
    $event->authorize();
    $event->stopPropagation();
  }
}

```

## Adding your own listener

If the core logic doesn't meet your needs, it is possible to get the symfony event dispatcher service and add either a listener (for single events) or a subscriber (for multiple events).

For example, to add a subscriber:

```
$subscriber = new MySubscriberClass();
\Civi::service('dispatcher')->addSubscriber($subscriber);

```

When your listener/subscriber is called, then call the `$event->getApiRequest()` to find out the parameters you are being asked to authorise. If the event should be authorised then call `$event->authorize()`.

# SQL clauses

For actions based on `get()`, the selectQuery-\>getAclClause() method will call `$baoName::getSelectWhereClause($tableAlias)` to add a where clause.

It doesn't seem possible currently to apply differing ACL logic depending on the action with this method.

---
Tags: api, acl
---


# Question
Title: How do I get CiviCRM Mailing to submit via the API
I would like to send a mailing every time a content item is published. The mailing is not being saved.

I have taken the sample code from

```
sites/all/modules/civicrm/api/v3/examples/Mailing/Create.php

```

Such as

```
$ht_node = $content['htnode'];
$the_subject = t('New Hot Topic Published: ' . $ht_node->title);

// Submit it now. No fussing.
$currentTime = new DateTime();
$approval_date = $currentTime->format('Y-m-d H:i:s');
$currentTime->add(new DateInterval('PT1H'));
$schedule_date = $currentTime->format('Y-m-d H:i:s');

$msg_params = array(
  'recipient' => 'Ecological Society Member',
  'htnode' => $ht_node
);
$content_templated = $this->themeEmail($content, $msg_params);

// drupal html_to_text leaves styles in place.
$text_no_style = preg_replace('|<style.*?</style>|mis', '', $content_templated);
$plain_text = drupal_html_to_text($text_no_style);

// see sites/all/modules/civicrm/api/v3/examples/Mailing/Create.php
// See query DataObject.php 1060
$params = array(
  'scheduled_date' => $schedule_date,
  'approver_id' => 21638,
  'approval_date' => $approval_date,
  'replyto_email' => self::REPLY_TO_EMAIL,
  'from_email' => self::REPLY_TO_EMAIL,
  'from_name' => self::FROM_NAME,
  'subject' => $the_subject,
  'body_html' => $content_templated,
  'body_text' => drupal_html_to_text($plain_text),
  'name' => $mailing_name,
  'created_id' => 21638, // Contact id of mailing creator
  'header_id' => '9',
  'footer_id' => '10',
  'groups' => array(
    'include' => array(
      '0' => $to_group,
    ),
  ),
  'mailings' => array(
    'include' => array(),
    'exclude' => array(),
  ),
  'options' => array(
    'force_rollback' => 1,
  ),
  'api.mailing_job.create' => 1,
  'api.MailingRecipients.get' => array(
    'mailing_id' => '$value.id',
    'api.contact.getvalue' => array(
      'return' => 'display_name',
    ),
    'api.email.getvalue' => array(
      'return' => 'email',
    ),
  ),
);

  // Throw error to the parent. Let the controller print out the error messages.
// Throws  CiviCRM_API3_Exception
civicrm_initialize();
$result = civicrm_api3('Mailing', 'create', $params);

if ($result['is_error'] === 1) {
  throw new Exception('Error in civicrm api mailing create: ' . $result['error_message']);
}

watchdog(HOTTOPICSNOTIFY_MODULE_NAME, '%mailing-name scheduled to be sent to group %groupid an e-mail. Mailing id is %mailing_id', array(
  '%mailing-name' => $mailing_name,
  '%groupid' => $to_group,
  '%mailing_id' => $result['id'],
));

```

I have run the debugger over it. The sql that is generated is fine - even inserts a mailing if I run it.

I can see no errors being returned, in Bao/Mailing.php it sees the scheduled\_date and passes the \_evil\_bao\_validator\_ test. $transaction-\>commit() is run.

There is no sign of this call in the civicrm\_mailing table or in the mailing screens.

How do I create and run this mailing?

# Answer
> 4 votes
Remove the force\_rollback block.

What is the result of the civicrm\_api3 call?

---
Tags: civimail, api
---


# Question
Title: How to create a Drupal View that calculates activity end time by duration
I'm trying to create a Drupal View table of CiviCRM activities that calculates the end time of the activity based on start time and duration.

So far I've got the unix start time of the activity, a math expression that turns duration into unix minutes and a math expression that adds the unix start time and the unix duration minutes to get the unix end time of the activity.

The final step is to convert that unix end time of the activity to a human readable time like 7:32 AM. All math expressions work correctly, I've checked the computed end time (expression\_1) field with unix converters.

I'm not certain where I'm hitting a wall but if I test the output with the Views PHP module (I'll code it into my template once I get it ironed out) using something like this:

```
<?php
print date('d-M-y g:i A', $row->expression_1);
?>

```

I get 31-Dec-69 7:00 PM as the output for every row. Which is the day prior to unix's base time of January 1, 1970.

I'd appreciate any guidance.

# Answer
> 4 votes
The template file is just to change how this one field is displayed.

Create a view of civicrm activities.
Add the Scheduled Activity Date field three times.
First to display the date.
Second to display the time in.
Third to convert the start date/time to Unix (I had previously added Unix as a time format in Drupal).

Then add Duration.

Add a Math Expression field to convert duration into Unix minutes.

Add another Math Expression field to add the Unix start time to the unix duration math expression.

Here is the final list of fields:
Save the view.

To create the template for this field we need to get the specific name for the template. In the Advanced section of the View, go to Theme:Information. Scroll though the listed fields until we get to the one we are interested in manipulating.

In our case it was the final field and the most specific template name available (templates are listed from least to most specific). Copy the last listed template.

Now create a new file and paste in the name you just copied. The name should end in tpl.php.

In the file put:

```
<?php
print date("g:i A", $output);
?>

```

Save this new template to sites/all/themes/current\_theme/templates where current\_theme is your theme name.

Flush cache and you should be good.

Here is the final result:

Notice that when you are editing the view, this field still displays in Unix time.

---
Tags: drupal, activities, drupal-views, dates
---


title: how to add a field in tags

text:
# Question
Title: how to add a field in tags
I would like to ask how to add more fields to the tags for each individual. We have a lot of individuals who are parents but we do not know where to define them as parents since we don't know the name of their children, can't use the "Parent of" in the Relationship category. So we would like to add more fields in the tags so that we can put more details to each individual in order to help us organizing the data and easier to retrieve the data we need. Actually we would also like to enter the event each parent attends but we couldn't find anywhere to do so. Please advice. Thanks.

# Answer
> 1 votes
I would suggest you create a contact sub-type called "Parent" (sub-type of Individial). This allows you to create a custom field group just for parents, and you can collect whatever additional information you wish.

# Answer
> 0 votes
you didn't indicate what version of Civi you're using (that's always helpful to other users, FYI) but the general answer to your question is that custom fields are unavailable on tags. However, you could create a group to which you can add parents who don't have defined parent/child relationships in Civi, and groups do allow custom field sets, I believe. As for events, I'm not sure why you wouldn't record their event attendance in the events tab of their contact record? (I realize that would require creating the events in Civi but that would allow you to capture and search for event attendance more easily.)

---
Tags: tags
---


title: Unit Tests on Single DB

text:
# Question
Title: Unit Tests on Single DB
My rig has a CMS & Civi combined database. This was to make life easier through drush sql-sync from @prod to @dev.

However, @dev is a vagrant box, with two databases, one for CMS, one for Civi.

When I run unit tests, instead of it cloning from the CMS database it clones from the old civi one.

My question is, how can I get it to clone from the CMS database? I've changed settings in the local test file and the civicrm.settings.php file.

# Answer
> 0 votes
Looks like the new, fledgling, e2e tests are my answer...

---
Tags: developer, phpunit
---


# Question
Title: Why does the Preview as HTML in civimail not apply the html that has been applied to the footer
Thought I was going round in circles here. Set html eg `<p><span style="font-family:Arial,Helvetica,sans-serif;">` to the Footer including both the Unsub token and the Domain Address token.

Preview mailing as HMTL in CiviMail. The Unsub text shows as intended, but the Domain Address shows as Times New Roman.

When I actually send a test mail, the domain address does show as sans serif. confusing.

# Answer
Check this out: https://issues.civicrm.org/jira/browse/CRM-17726

Contents in the body tag get deleted on load. When you resave they get nuked.
> 2 votes

---
Tags: civimail, html, header-footer
---


# Question
Title: first click to reach CiviCRM dashboard results in long delay and error message
I am managing a Drupal site and when I first log in and click CiviCRM menu link, there is a long delay followed by this message:

> Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

I have increased the PHP max execution time, and it did help to eliminate this message, but the message is happening again. I also increased the memory limit to huge.

Can someone tell me how to set some debugging or logging to show me what exactly CiviCRM is doing during this delay?

Drupal 7.5.2. MySQL 5.5.52-MariaDB. PHP 5.6.30 as FPM. CiviCRM 4.7.16.

thanks!

# Answer
I updated the Drupal core to version 7.54 using "drush upc", which reported pending database updates, so I also did "drush updatedb". The Drupal core update also caused several "projects" to be updated as well.

All of this seems to have cleared the problem I originally reported – I no longer see a long delay when I first log in and click CiviCRM.
> 1 votes

---
Tags: drupal, dashboard
---


# Question
Title: How can I assign an External Identifier to each set in a multi-record import?
I'm importing education history for each Individual Contact, which can have from 0 to 5+ sets of multi-records. Each set of multi-records comprises \[institution\], \[degree level\], \[degree name\], and \[grad year\].

The level, name, and year are custom fields that show up in the multi-import wizard. The institutions are already imported as Organization Contacts with their own external IDs, and I have a relationship set up between individuals and educational orgs (much in the same way as employees would be related to employers).

However I don't see a way in the multi-record import wizard to relate a set of education multi records with the corresponding institution's External ID. Is there a way to do this in the wizard?

If not, is there a way to do it directly in MySQL? (Though I hesitate to muck with the guts, since last time I changed some seemingly innocuous data, the site got corrupted.)

With hundreds of records to import and limited manpower, a manual process is likely not feasible.

# Answer
We are upgrading from CiviCRM 4.6 to 4.7.17. The Eternal ID is now available for matching to contact records for importing multi-record custom data sets. I just completed a test and the import worked fine and matched using the External ID.
> 2 votes

---
Tags: import, multi-record
---