# Question
Title: What's the recommended way to handle redirection after quickform submissions?
I often find myself writing calls to CRM\_Utils\_Redirect in my postProcess methods.

But in core code I don't see this. I see the use of methods like $session-\>replaceUserContext and postProcess functions that end seemingly without telling me where to go next.

I feel like CiviCRM is often clever enough to go to load different pages on form submission based on where you came from. I have no solid proof of that but lets give Civi the benefit of the doubt on that one :)

I'm guessing there is a structure somewhere that is telling CiviCRM what page to load next but I have failed to spot what that is.

I'm interested in the canonical way that CiviCRM does this (if there is a canoncial way) and knowing how legacy that is, and also what I *should* be doing.

If anyone could enlighten me, I'd be grateful :)

PS. I am not so interested in "you should write that in angular" enlightenment, at least not in the answer to this question.

# Answer
> 4 votes
Use the built in button **types** and corresponding `CRM_Core_QuickForm_Action_*` classes that are invoked when those buttons are clicked.

For example, clicking on a button created with

```
$this->addButtons(array(
  array(
    'type' => 'submit',
    'name' => ts('Submit'),
    'isDefault' => TRUE,
  ),
));

```

Will call `CRM_Core_QuickForm_Action_Submit->perform()` which redirects you to the value of `$form->controller->_destination` (and if `$form->controller->_destination` is not set, will display the form again).

So in the simplest case, you can just add a line along the lines of the following to your form:

```
$this->controller->_destination = CRM_Utils_System::url('civicrm/something', 'reset=1');

```

Probably the best way to understand the other actions is to have a look at the `perform()` methods in the `CRM_Core_QuickForm_Action_Submit_*` classes.

GinkgoFJG's answer (and possibly Erik's) works when the button type is 'done', which makes sense when you have a look at the comments the inline code documentation for `CRM_Core_QuickForm_Action_Done->perform()`.

```
// Processes the request.
// [...] validate the page
// and if success, call post process
// when done processing pop to user context

```

# Answer
> 3 votes
Here is what I do in a page:

```
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/pumexpenseclaims/page/claimlevel', 'reset=1', true));

```

Then in the form I do nothing in the postProcess. The only thing I take into consideration is when I press something like delete on the page where I take an action but do not need a form. If that is the case I tend to do this:

```
$session = CRM_Core_Session::singleton();
CRM_Utils_System::redirect($session->readUserContext());

```

Mind you, it could well be that this pattern no longer works in 4.7? What are the issues you run in to?

# Answer
> 1 votes
I tend to set the userContext in my page, which will then make my form return to where I wanted it. Does that make sense?

# Answer
> 1 votes
Here's how Volunteer does it:

---
Tags: developer
---


title: CiviVisualize and permissions

text:
# Question
Title: CiviVisualize and permissions
We are using CiviCRM 4.6 with Drupal 7. We have CiviVisualize 1.42 installed and think it's pretty great. We just found a wrinkle though and wondered if the issue is with the extension or our (lack of) setup.

We have a few Drupal roles that do not have access to CiviContribute. Yet when those users navigate to the CiviVisualize section (oursite.org/civicrm/dataviz) they are able to see the CiviContribute section at /civicrm/dataviz/contribute and the Donor Trends (with specific donor names!) at /civicrm/dataviz/donortrends.

I don't see any CiviVisualize permissions in our Drupal permission list and I can't think of how Civi permissions (ACLs) would/could impact the extension's permissions. I also don't see a CiviVisualize setup page within Civi that might have settings for permissions.

Any ideas? Does CiviVisualize follow permissions from the CMS and I'm just not seeing how to set it up, or would we need to do something different to get CiviVisualize to respect our permissions? Thanks for the help!

# Answer
I've taken a look in the code, and it looks like CiviVisualise/Civisualise/Civivisualise the missing CiviCRM visualisation extension (:P :P :P) uses direct SQL commands, meaning that certain CRM features such as ACL checks would be bypassed.

This would need changing at a code level, I'm sure Xavier would love to hear from you.

JohnFF
> 1 votes

# Answer
We kinda got around this by adding some permissions to civizualise.xml:

`<access_arguments>access CiviCRM, view all contacts</access_arguments>`

Not as good as the proper ACLs, but works ok. As JohnFF says, civizualise uses direct SQL so I imagine ACLs wouldn't be an easy thing to add.
> 0 votes

---
Tags: extension, permissions
---


# Question
Title: Is it possible to change the Invoice numbers that are used in CiviCRM?
I have a customer that is wanting to customize/assign invoice numbers to each receipt/invoice for event registrations rather than the long and completely random ones that CiviCRM puts out and not just for those who select "Pay Later". Is this possible to do? Is it possible to have it reflect for all CiviEvents going forward?

Any help would be greatly appreciated. :)

Using: CiviCRM 4.6.8 Drupal 7

Thank You, Nicole

# Answer
The invoice ID it shouldn't be a random number, I might be wrong but I believe under normal circumstances (unless an extension is already hooking in the contribution entity) the invoice ID is taken from the contribution ID.

As I'm not quite sure what is exactly what you want to achieve, here are some thoughts, I won't elaborate too much.

If what you want is to manually assign a invoice number, you can create a custom field, create a custom token for the given field and edit the invoice template (navigate to Administer - Communication - Message Templates - System Workflow Messages - Invoice receipt) replacing the invoiceID with your custom token.

If you want the custom invoice ID to be generated automatically every time a new contribution is submitted, I don't think there is a straight forward way to do it, as you will need an autoincrement value, and I can't think of an easy way to do that, mysql only allows one autoincrement column per table and when creating a custom filed, Civi creates a new table in the database with a autoincrement column, maybe some of the core team could point you in a better direction.

My thoughts:

* (a bit of a workaround, maybe not the best way as I said) create a custom field group with an INT text/numeric field, using the appropriate hooks, save that filed in every Contribution submission and copy the value of the ID (autoincrement column) of the custom filed group to the custom filed itself so you can search by invoice id, create the custom token and modify the invoice template.

Hope I explained myself.
> 2 votes

# Answer
Under Admin \> CiviContribute \> CiviContribute Component Settings, after turning on Sales Tax and Invoices, you have an option to change the prefix of invoices. The number itself is indeed the contribution number, which means it is unique and monotonically increasing.

It wouldn't be too difficult to replace it everywhere with an extension: contribution view, contact dashboard, possibly contact summary contribution tab, find contributions, advanced search, and a bunch of reports would be where I'd start.
> 1 votes

---
Tags: civievent, drupal, civireport
---


# Question
Title: Image not displayed in the email with outlook
I have created a new mailing with an image(logo) in the text. Contacts which use outlook to open the email doesn't see the image.

The problem is the same if the image is in the template or added in the mailing.

To avoid this issue, if I go in the source of the mail and remove tag, the image is displayed in outlook.

Do you have an idea how-to definitively resolve this issue? Regards,

# Answer
> 1 votes
This is almost certainly a characteristic of Outlook rather than a problem with Civi. Outlook won't necessarily display images - certainly if the 'from' email address is a new one to that Outlook - so the user has to check a flag to indicate that they want see images for that email address. Other email systems also behave in a similar way - it's a (sort of) security feature.

---
Tags: civimail, email, images
---


# Question
Title: Drupal Forms + Civicrm Contributions, Doesn't process Contribution?
I'm using Drupal 7.43, civicrm 4.7.4., drupal webform 7.x-4.5, and webform civicrm integration 7.x-4.13.

I made a form that would allow users to apply for paid membership. There are a few pages of civicrm tied fields (asking for name, address, other relevant questions), and then a page that ties to a civicrm contribution page.

However, when I test out the page there is some weirdness with the contribution page. The form loads settings from the civicrm contribution page, including a button to 'submit contribution'. Below this is the arrow buttons to go forward or backward on the webform.

When I click just on the button to go forward to the preview page, it goes to the preview page, but the contribution is not processed. If instead I click on the 'Submit Contribution' button, it acts as though I clicked the 'previous page' button and still doesn't process the contribution.

Any thoughts on what might be causing this?

I tried out the contribution page without the Drupal form, and it processed the payment. So I think it's related to the Drupal form.

# Answer
I understand that this has been fixed in updates. Not sure the exact bug or feature request, but it's worked on our site since I made this question.
> 0 votes

# Answer
See Payment form broken on CiviCRM 4.7
> 2 votes

---
Tags: drupal, webform-civicrm, contribution-page
---


# Question
Title: Confusion between Contribution ID vs Invoice_ID in the database
CiviCRM 4.6 - Moneris payment processor -

CiviCRM's invoice uses the ID column to generate the Invoice number (INV\_XXXXX) but creates its own hash and adds it to the invoice\_id column - is there a way to reconcile the two? It seems CiviCRM uses the ID column to reference a contribution everywhere except in the invoice\_id column after a successful transaction as been made.

We notice that when "Send Invoice Email" is used in the Contribution view, it changes the invoice\_id column to the INV\_xxxxx naming which has given our client major reconciliation headaches. Based on the database logging, the "Send Invoice Email" function sends an Insert request and updates the invoice\_id field.

I tried searching the issues tracker, but couldn't find anything.

Before and after images included -

# Answer
It looks like in CiviCRM 4.6, the invoice\_id hash gets replaced by the INV\_xxxxx number the moment there's an "action" taken - the invoice is downloaded or edited, for example.

Not sure why.
> 1 votes

# Answer
This answer is significantly revised based on feedback from colleagues here and in Mattermost, and a bit of subsequent research.

The contribution ID column is a good unique reference field.

I had forgotten about the hash value being placed in the invoice\_id field. It seems that very long ago Lobo (2007) started to put a unique hash value in this field to facilitate reconciliation with online payment processors, which later migrated into the code for various payment processor integrations. I don't think this is a good name for a field storing data for that purpose, nor is a hash a good invoice number. I suppose there is a field called invoice id on some payment processors that can accept an ID from CiviCRM which is ideally unique. The problem is that a hash value is not a human friendly value for an invoice, and best practices for auditing would want to see that no invoices have been issued that are not still in the system, which is best facilitated and made auditable by a consecutive numbering scheme or similar. I do think that the way the field was used for manual entry of invoice numbers makes sense.

There was a different field, trxn\_id, also added in v. 1.3, that is now in the civicrm\_financial\_trxn table, that was intended to be used to store unique numbers received from payment processors. Perhaps it would have been good, or still could be good, to use this field instead for a unique value intended to match civi to payments in these external systems.

A further and more important problem with the way this invoice\_id is stored and used currently by several payment processors is that CiviCRM has supported partial payments on events for a few years. The schema was changed to support this i 4.3 or 4.4 by me and dgg. I think it was spec'd and funded for 4.5 by CompuCorp and implemented by WebAccess and overseen by dgg (I wasn't involved).

Partial payments has since been extended to regular contributions and memberships. During this partial payments work, the payment specific information has been stored in the civicrm\_financial\_trxn table since that allows one record per payment. There is no way to track multiple payments on a contribution using a field on the contribution record like invoice\_id.

The INV\_12228 invoice id was added in 4.6 to provide a valid invoice id that complies with UK law for invoice numbers. The bad part was that when it was implemented it would have been nice to notify the maintainers or fix the code of the relevant payment processor plugins that were (still) using this field to correlate payments with the external systems.

At this point my suggestion is that interested parties should scope work involved in fixing this. One option would be to migrate data from civicrm\_contribution.invoice\_id to civicrm\_financial\_trxn.trxn\_id and update code to store this way. If some processors use both trxn\_id and invoice\_id then we should create an invoice\_id on civicrm\_financial\_trxn table, migrate data as appropriate, and also update the code to store info in this new location.
> 0 votes

---
Tags: civicontribute, invoice
---


title: PayPal Pro IPN Method missing

text:
# Question
Title: PayPal Pro IPN Method missing
When making recurring contributions, everything works fine when entering credit card info directly, but if one uses a PayPal account, the method (m=contribute) is missing in the IPN generated

(i.e., i=0c1df32e5c4f32d4f8ef1c2fe8e&m=&c=11058&r=95&b=465&p=14)

It should read i=xxxx&m=contribute&c=... like it does for IPNs generated using credit cards directly.

The recurring profile shows the status as Pending and the contributions show as Pending (Incomplete Transaction) in Civi through they are completing properly in PayPal.

Is this a bug or something on my side!?!? Running Civi 4.7.15 in WP. Any help is appreciated - thanks! Karen

# Answer
Is this paypal pro or standard? For paypal pro all IPNS except for recurring are actually ignored, the outcome is resolved in realtime (ideally the IP would be a backup but Civi code doesn't implement that)
> 1 votes

---
Tags: payment-processor, paypal, recurring-contributions, ipn
---


title: Linking Price Set to new event

text:
# Question
Title: Linking Price Set to new event
I must have missed this step, I have the price set all updated but it I cannot find where to link to this years new event. I appreciate your help. tj

# Answer
Go to Manage Events

Find the Event

Click on Configure and then to Fees and set the Price Set there
> 2 votes

---
Tags: civievent, price-sets
---


# Question
Title: Include tags or groups in Advanced search views?
Is it possible to display a contact's tags in an advanced search listing? I was hoping to make a 'Search Views' profile including the tags field and then have this column show up in the results of an advanced search.

However, when I go to make a tag field in the profile, the option to choose 'results column' disappears as soon as I choose Contacts \> Tags.

I guess that's to stop multiple tags from clogging up the search display results. But I want to see those multiple tags...

I've tested this in civicrm demo 4.6. And have the same in our system; we're using 4.6.24 and Drupal 7.54.

So is there a way to make this happen?

Thanks for your help.

# Answer
> 2 votes
In Advanced Search - I don't think that is possible now due to the reason mentioned in the question. But it could be fixed by filing a JIRA/PR etc.

Workaround - Use Search Builder and fire a query for tags not null. Similar to -

Hitting Search would display multiple tags in search results.

---
Tags: search-results
---


# Question
Title: Ajax Error when trying to view relationships tab
Civicrm 4.7.1 Joomla 3.4.8

I'm unable to view data in the relationships tab. I get the following errors:

"DataTables warning: table id=DataTables\_Table\_0 - Ajax error."

And

"DataTables warning: table id=DataTables\_Table\_1 - Ajax error."

This issue has been ongoing since updating to 4.7.0

Any help would be appreciated. Please let me know if you need additional information.

Thanks.

# Answer
> 3 votes
I had the same issue. CiviCRM 4.7/Drupal 7/IIS8 configuration. The Ajax call was generating a query longer than what the web server was configured to handle and behind the scenes the web server was throwing an error, but it is not logged to the Civicrm log nor the Drupal log.

I was able to solve this by increasing the query string length in IIS.

* In IIS Manager select the site
* Choose the Request filtering icon
* Navigate to the query string tab
* Click the edit feature settings
* Change the Maximum query string (Bytes) from 2048 to 4096 or something larger

Contact Relationships now show properly.

# Answer
> 2 votes
I am seeing this on 4.6.14 . This is due to modsec thinking it is a SQL attack. I saw a popup indicating datatables saw an error and to look here:https://datatables.net/manual/tech-notes/7

Console showed these errors:

> Failed to load resource: the server responded with a status of 403 (Forbidden) https://www.xxxxxx.com/civicrm/ajax/contactrelationships?context=past&cid=10…\_9=false&mDataProp\_10=10&bSortable\_10=false&iSortingCols=0&\_=1462288897639 Failed to load resource: the server responded with a status of 403 (Forbidden)

When I disabled the modsec rule it worked without error. here is the rule: SecRule ARGS|ARGS\_NAMES|REQUEST\_COOKIES|REQUEST\_COOKIES\_NAMES|XML:/*|!ARGS:/body/|!ARGS:/content/|!ARGS:/description/|!ARGS:/message/|!ARGS:Post|!ARGS:desc|!ARGS:text|!ARGS:text\_message|!REQUEST\_COOKIES:/\__utm/|!REQUEST\_COOKIES:/\_pk\_ref/|!ARGS:sql\_query "@rx \[\[\]\\"',().\]{10}$|(?:union\s+all\s+select\s+(?:(?:null|\d+),?)+|order\s+by\s+\d{1,4}|(?:and|or)\s+\d{4}=\d{4}|waitfor\s+delay\s+'\d+:\d+:\d+'|(?:select|and|or)\s+(?:(?:pg\_)?sleep(\d+)|\d+\s*=\s\*(?:dbms\_pipe.receive\_message((?:chr(\d+)(?:\s\*\\|\\|\s\*)?)*,\d+)|(select\s+\d+\s+from\s+pg\_sleep(\d+)))))(?:\s*(?:and|or)\s+(?(?:(\d{4})=\1|'(\w{4})'='\2|'%'=')|--\s\*\w\*|#)$|(select\s\*(case\s+when\s\*(\d+\s\*=\s\*\d+)\s+then\s+\d+\s+else\s+(?:0x\[\0-9a-h\]+|\d+)\s+end))|(?:(?:and|or)\s+(?'?(?:\w{1,4}|%)'?)?(?:=|\<|\>)(?'?\w{0,4}'?)?|order\s+by\s+\d+)(?:#|--\s\*\w{0,4})?$" \ "id:1,rev:5,msg:'COMODO WAF: SQLmap attack detected',phase:2,severity:2,capture,block,setvar:'tx.sqli\_points=+%{tx.points\_limit4}',setvar:'tx.points=+%{tx.points\_limit4}',logdata:'Matched Data: %{TX.0} found within %{MATCHED\_VAR\_NAME}: %{MATCHED\_VAR}',ctl:'auditLogParts=+E',t:'none',t:'urlDecodeUni',t:'lowercase'"

# Answer
> 1 votes
This sounds like a bug you could probably report the bug the issue tracker: http://issues.civicrm.org

As 4.7 is verly new it might contains a few bugs.

# Answer
> 1 votes
I have tested the above issue against WP 4.6.1 and CiviCRM 4.7.11. I am running Apache 2.4, php 5.6 and MySQL 5.6. The OS is CentOS 6.

I cannot reproduce this error nor the one mentioned AJAX error when viewing contact groups

I commented in https://issues.civicrm.org/jira/browse/CRM-19331 about this as well.

I would suspect the issue here is due to either a plugin conflict or something specific to the Hosting Configuration. I am interested if these issues are specific to a host or a specific configuration.

I'd disable all plugins (except CiviCRM) and see if you can trace errors in you apache and php logs. I would also revert to a default theme (CiviCRM demo sites are tested with TwentyThirteen) I'd also look at the CiviCRM logs. The CiviCRM logins should be in the `/civicrm/ConfigAndLog` directory that is stored in the WP upload directory in 4.7

I'd be interested if these issues are specific to a host or a specific configuration.

# Answer
> 1 votes
I had a very similar issue. It turned out to be a limitation of the web-server on the maximum number of characters in the GET request. It was set to 2048 characters, whereas the request was bigger than 2200 characters. Increasing the limitation on the webserver solved my issue.

---
Tags: relationships, database, error, ajax
---


# Question
Title: Donations Page with recurring and one time
Is it possible to design a single donation page that offers both recurring and one time? I'm trying to avoid two separate forms.

I have Webform for Civi setup as well as eWay.

If yes, any links would be appreciated.

Thanks.

# Answer
I'm not sure about the integration of this with Webforms (I assume you can do it), but if you can use a regular CiviCRM contribution page, you'll be able to set up a page that offers both recurring donations and one time donations.

Under Contributions\>Manage Contribution Pages\>"Your contribution page"\>Amounts tab

You will see a field to define fixed donation amounts:

You will also see a field to define whether you'd like people to define their own donation amounts:

The third field you want to pay attention to is for defining recurring contributions as you'd like to. This will put a checkbox where a user can decide whether they want to make a recurring donation or a single donation:

Put it all together... and your CiviCRM contribution page will look something like:
> 1 votes

# Answer
Since recently - you can also do this in webform\_civicrm! It works a little different in that a donor can select an amount -\> and then the donor can specify whether to pay this:

1) in one go; or 2) in installments - and of course the installment part is completely configurable a la webform components \[whether you let the user select options or whether you set specific ones\].

If the donor selects an amount that can't be divided by the #installments it will automatically round down the subsequent installments and charge a little more for the first one;

**Example:** How do I configure the new recurring contribution feature in Webform CiviCRM module?

That's for an Event Registration - webform\_civicrm does not care if you do Contributions or Event Registrations (or Memberships);
> 0 votes

---
Tags: contribution-page
---


# Question
Title: Command failed (cv php:boot --level=settings) when trying to run tests
I'm trying to run CiviCRM's unit tests, but I hit on this error when running scripts/phpunit AllTests:

```
RuntimeException: Command failed (cv php:boot --level=settings) in ...tests\phpunit\CiviTest\bootstrap.php

```

This is on the master branch of CiviCRM on a local development machine.

* Using Windows 7 with a XAMPP stack
* PHP Version 5.6.15
* The civicrm-core directory is up to date with the master branch

# Answer
> 2 votes
I recommend you install and use buildkit: https://github.com/civicrm/civicrm-buildkit

It comes with lots of tools - including those you need to run tests.

I use it on MAMP but from what I understand this will work on Windows as well.

Alternatively - if you like you can also: https://github.com/civicrm/civicrm-buildkit-vagrant

# Answer
> 1 votes
Just adding some steps to check if basic things are met correctly.

1. Make sure you are in civicrm folder when you run the test.

```
$ cd <site_name>/sites/all/modules/civicrm
$ export CIVICRM_UF=UnitTests
$ phpunit4 tests/phpunit/api/v3/ContactTest.php

```
2. Is your **civicrm.settings.php** file searchable? Add the below line to your `~/.bash_profile` file.

```
export CIVICRM_SETTINGS=/Users/jitendra/www/civicrm-master/sites/default/civicrm.settings.php

```
3. If you have cv installed and `cv vars:fill` runs fine, check if `civicrm.settings.php` values are correct($civicrm\_root, CMS\_DSN etc).

# Answer
> 0 votes
cv is a command line tool that's not included with CiviCRM. The repo can be found here: https://github.com/civicrm/cv

This command line utility seems to be required to run phpunit tests in Civi. (Though I'm not sure yet whether it runs on Windows systems).

---
Tags: developer, testing
---


# Question
Title: Adding settings with form to my extension - what am I missing?
I would like to add a settings form to a new extension to hold some extension-specific settings.

I've put together the extension and form using civix, and am testing in civiCRM 4.7.17 on local MAMP.

After reading the docs here and here, i've tried to copy the setup for settings in this repo (metadata form example from docs), and also looking at this repo.

I've looked at this question, but the issue i'm having is getting the settings array returned from settings/'myextension'.settings.php to actually populate anywhere in the first place.

For example when installing/enabling the extension, hook\_alterSettingsFolders fires with the same code as in the above repos, but if I try to find my settings with the apiv3 call like this form (the one I used as well) does, the settings group has not been added, and so my form only populates with submit buttons and a var\_dump of $\_settings is empty.

I'm not seeing anything obvious in the civicrm or php logs.

Is there some key step i'm missing to get civicrm to recognize these settings?

Thanks!

# Answer
> 1 votes
Perhaps another example will help you along:

The Form: https://github.com/jake-mw/CDNTaxReceipts/blob/master/CRM/Cdntaxreceipts/Form/Settings.php

And some of the settings are retrieved here: https://github.com/jake-mw/CDNTaxReceipts/blob/master/cdntaxreceipts.functions.inc#L73

---
Tags: extension, developer, settings
---


# Question
Title: Event Custom Fields not Looking Right with 4.6.27 Upgrade
I'm trying to upgrade our site from 4.4.21 to 4.6.27 (latest LTS). The upgrade process, following the guide, worked as expected and everything looked ok initially. However, when I try to create a new Event, several custom fields don't work and don't look right.

The contact reference autocomplete-select fields don't auto-complete (nor do they load the little icon next to the field, the js isn't loading). And the date fields look really off, with two fields and the calendar icon doesn't pop up a calendar.

This is only on custom fields for events. Standard date fields are fine, it seems.

The only error I could find was in the Console, with this message right as it's loading the custom fields. I don't see any errors in the apache logs nor on screen (I have debugging turned on). So I'm at a bit of a loss on how to debug this.

> Error: cannot call methods on autocomplete prior to initialization; attempted to call method '/civicrm/ajax/contactref?context=customfield&id=129'

I thought it might be some custom module I have, but I've disabled everything and still get these odd custom fields. Would appreciate help in figuring this out.

# Answer
Often JS errors after an upgrade are caused by needing to clear the browser cache. Give that a go and retry.

Another approach to resolving this is to try to create new equivalents of those fields once the upgrade has run, and see if they behave in the same way. This is distinct from what you did in your subsequent comment.

John
> 1 votes

---
Tags: custom-fields, 4.6
---


title: Contact type change

text:
# Question
Title: Contact type change
Is it possible to change "contact type" for a batch of records rather than go into each one at a time? I have found the records I want to change, but "change contact type" does not seem to be a batch option offered.

# Answer
You can not change the contact type in a batch as a contact type also has some functionality in it. For example a Individual does not have a value in the field `organization_name` and an organization does not have a `gender_id`.

So you have to change the contact type in a program, using the API Explorer or directly in the database. And for both: be careful!

The Contact Editor extension allows you to change contact types safely. It checks for potential data loss, which isn't possible with the API method or the Merge method.
> 4 votes

# Answer
If you're going eg from Individual - A to Individual - B and you have made double sure there are no custom fields that can go missing - then you can use mysql on the command line to update Contact Types for a set of given contacts en bulk.
> 2 votes

---
Tags: civimember
---


# Question
Title: Recurring donations are receiving recurring email receipts after update
I updated to 4.6.27, and recurring donations started re-sending out email receipts each month. The old behaviour was to send an email receipt when they made their contribution but not a monthly email. I'm using the Stripe payment processor.

# Answer
We do not use Stripe so this might not help. But this is how it works for iATS.

Go to Administer \> CiviContribute \> iATS Payments Settings (the very bottom option) One of the check boxes is "Enable email receipting for each recurring contribution" If this is checked you will be sending a receipt with each donation.
> 3 votes

---
Tags: civicontribute, email, receipts, recurring-contributions
---


# Question
Title: civicrm.org website old what/whatiscivicrm redirect to explore-civicrm
I am using my older, ancient 4.4.5 wordpress version of civicrm (I am about to upgrade it) but I think this link is hard coded. In my site when going to the menu Help...About it links to

https://civicrm.org/what/whatiscivicrm

I get "page not found". To make the user experience of all old civicrm installations one step better and not make them take the time to look for an updated link like I had to do I think it should redirect to

https://civicrm.org/explore-civicrm

I believe https://issues.civicrm.org is where this needs to get reported eventually but I wanted to ask here first.

What next step can people recommend?

# Answer
I've added this redirect, thanks for reporting it!

I think it's great you've made the effort to post it somewhere we can field it, and that the end result is more important than correct process - so don't fret about not posting it on issues.civicrm.org this time. Thanks for being part of the community! You did this to benefit others in your situation, knowing you wouldn't benefit yourself, and that's priceless.

Your next step is to finish that upgrade of your old CiviCRM to a supported release ASAP

Hop on over to https://chat.civicrm.org to discuss.
> 1 votes

---
Tags: wordpress, webserver, 4.4
---


# Question
Title: Changed behavior in handoff between CiviContribut and PayPal
We're encountering a problematic changed behavior in the CiviContribute module when it hands an online contribution over to PayPal Standard for payment.

The purchase description used to be like this:

Online Contribution: Sponsor a Child

which made it very easy for our treasurer to assign the payment accordingly.

The purchase description now appears like this:

1092-4219-Sponsor a Chil

where the first number is the contact ID and the second is Civi's internal contribution ID -- neither of which is very useful to the treasurer. Meanwhile the purchase purpose is truncated making it harder to figure out where to assign the payment in the back end accounting.

We are running Civi 4.7.14 in a Wordpress CMS. It looks like the changed behavior might have begun when we upgraded from 4.6.X to 4.7.14.

Questions:

a. Is this a "feature" or a "bug"?

b. Is there a setting or template that we can adjust to get back to the original behavior or otherwise control the product description that is handed to PayPal?

# Answer
It's documented and resolved in JIRA

https://issues.civicrm.org/jira/browse/CRM-19863
> 1 votes

---
Tags: civicontribute, paypal
---


# Question
Title: How can I use <html>, <head>, <body> tags in a mailing?
As a follow-up to: How do I override the default CKEditor configuration?

**The issue**

We have a custom email template that uses `<html>`, `<head>`, `<body>`. When using either the CKEditor main 'email body' editor, or the standard textarea when creating a custom header/footer, these tags are stripped out.

Is this a combination of CKEditor and CiviCRM both stripping out these tags separately?

**I've tried...**

I originally tried adding the CKEditor config option `fullPage=true` . This works, but automatically adds `<html>`, `<head>`, `<body>` to *every* CKEditor instance (cross-posted here) .

But then I spotted that the `<html>`, `<head>`, `<body>` tags are also stripped if used within header and footer templates, as described in this forum post. And these fields do not use CKEditor.

# Answer
There is a good, baked-in solution for this now. Thanks to work by Coleman:

You can add the fullPage = true setting to the CKEditor configuration just for CiviMail in:

Administer \> Customize Data and Screens \> Display Preferences \> Configure CKEditor \> CiviMail tab \> Advanced options \> Set fullPage = true as an option.

Source: https://github.com/civicrm/civicrm-core/pull/9419#issuecomment-261834710
> 1 votes

# Answer
Not a good solution but what you can do is disable Advanced Content Filter (ACF) in ckeditor by editing the config.js file in the ckeditor folder like this:

```
config.allowedContent = true;

```

See documentation for more info.

What I do is extend the ACF like this:

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

[ ] // for attributes

{ } // for styles

( ) // for classes

```

That way you prevent ckeditor from striping html, body, head, id's or any element tag or even attributes that you need, but it won't add the default html-\>head-\>body by default (the behaviour with fullPage = true). The downside is that you will have to add the line on each CiviCRM upgrade, and i don't belive it will work with header/footer templates, I haven't tried it though.
> 3 votes

# Answer
Another option: **Don't use those tags in your email.**

If you actually need a `<title>` in your email, sure, this isn't for you.

For the majority of cases, it's unlikely those top-level tags actually are required elements in the email content or design.

By replacing them with regular block-level elements like `<div>`, and updating the CSS to reflect these changes, you may find this sort of workaround isn't necessary at all.

That can keep things much simpler.
> 2 votes

# Answer
Can you add your custom email template to Civicrm Administer/Communication/ Message Templates (Add Message Template)? Then you can edit/paste in your tags such as , in the HTML section ( assuming you would be able to send the mail from civicrm, I don't know your context)
> 1 votes

# Answer
Bit hacky, but you could try including the necessary text via a smarty include. Turn on smarty for mail templates, copy the content from your template into a .tpl file then put it in the templates directory (or in the templates folder in an extension). Then include in the visual editor with:

{include file=CRM/membership.tpl} (or as appropriate)

You'd need to edit this file manually, outside of Civi, but it should stop CKeditor messing about with the content.

(FYI we had odd problems with the presence/non-presence of the $ sign in smarty tags when we included files like this, but that was a few versions ago so that bug may have been fixed by now.)
> 1 votes

# Answer
Our temporary solution is to customise the crmUi.js file that defines the CKEditor configuration for the mailing HTML body. The patch file for this, if anyone's interested, can be found here: https://gist.github.com/JKingsnorth/d89fc355ee3d43d3adfc
> 1 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, ckeditor
---


title: civicrm report access

text:
# Question
Title: civicrm report access
I am trying to limit access to reports using acl/groups as mentioned in the userguide :

https://docs.civicrm.org/user/en/4.7/reporting/set-up/#define-report-settings

However, the field to set this does not appear.

Is there something i have to configure to make this appear? Or does this functionality no longer exist?

If relevant I am already using acl for controlling access to custom data sets.

Running civicrm 4.7.17 on wordpress 4.7.3 using php 7.0.15

UPDATE 1:

looking through the code it seems that the following code (found in /wp-content/plugins/civicrm/civicrm/CRM/Report/Form/instance.php) is causing it not to appear:

```
if (function_exists('user_roles')) {
        $user_roles_array = user_roles();
        foreach ($user_roles_array as $key => $value) {
          $user_roles[$value] = $value;
        }
        $grouprole = &$form->addElement('advmultiselect',
          'grouprole',
          ts('ACL Group/Role'),
          $user_roles,
          array(
            'size' => 5,
            'style' => 'width:240px',
            'class' => 'advmultiselect',
          )
        );
        $grouprole->setButtonAttributes('add', array('value' => ts('Add >>')));
        $grouprole->setButtonAttributes('remove', array('value' => ts('<< Remove')));
      }

```

For some reason the 'user\_roles' function does not exist.

So when the below code is run (found in /wp-content/uploads/civicrm/templates\_c/en\_US/%%48/48E/48E22AAC%%Instance.tpl.php) the php returns nothing:

```
<tr class="crm-report-instanceForm-form-block-role">
        <td class="report-label" width="20%"><?php echo $this->_tpl_vars['form']['grouprole']['label']; ?>
</td>
        <td><?php echo ((is_array($_tmp=$this->_tpl_vars['form']['grouprole']['html'])) ? $this->_run_mod_handler('crmAddClass', true, $_tmp, 'huge') : smarty_modifier_crmAddClass($_tmp, 'huge')); ?>
</td>
      </tr>

```

UPDATE 2:

looking a little higher in instance.php it looks like this might not be for wordpress even though this section still runs:

```
if ($config->userFramework != 'Joomla' ||
      $config->userFramework != 'WordPress'
    )

```

still unsure of why 'grouprole' doesnt exist for the other code though:

```
<tr class="crm-report-instanceForm-form-block-role">
        <td class="report-label" width="20%"><?php echo $this->_tpl_vars['form']['grouprole']['label']; ?>
</td>
        <td><?php echo ((is_array($_tmp=$this->_tpl_vars['form']['grouprole']['html'])) ? $this->_run_mod_handler('crmAddClass', true, $_tmp, 'huge') : smarty_modifier_crmAddClass($_tmp, 'huge')); ?>
</td>
      </tr>

```

# Answer
> 1 votes
I think this is a CMS issue. I see those options available at Drupal Demo but not at WP Demo

# Answer
> 1 votes
A temporary fix

I have managed to make it appear by modifying the code, though this isnt an ideal solution as updating will probably remove the change.

By replacing this (in instance.php):

```
if (function_exists('user_roles')) {
        $user_roles_array = user_roles();
        foreach ($user_roles_array as $key => $value) {
          $user_roles[$value] = $value;
        } // also remove the ending if bracket

```

with this:

```
$lib = URE_Lib::get_instance();
        $lib->get_user_roles();
        $user_roles_array = $lib->get('roles');
        $count = 1;
        foreach ($user_roles_array as $key => $value) {
          $user_roles[$count] = $key ;
          $count++;
        }

```

the wordpress user roles appear allowing the reports to be restricted based on wordpress roles.

It would be nice to see a proper solution for this.

---
Tags: wordpress, civireport, 4.7, acl
---


# Question
Title: How to streamline setting up a multi-day class
I'm using CiviCRM for, amongst other things, recording registration and attendance for short (1-2 week) adult education classes. I would like to be able to register each learner for the class and then be able to record their attendance on each day.

I can set up repeating events for each day, but whether I set the repeat up first then register the participant, or the other way round, the participant is only registered on the specific event chosen and not the others in the repeating set. If I make one event span the multiple days, I only get one attendance status for the whole thing.

I can just register them for each day, but that's extra work for our staff and adds potential for mistakes, so I'd rather not do that if there's a better way.

The registrations will be done only by our staff, there's no 'self service' online registrations.

CiviCRM 4.7.15 on Drupal 7.53.

# Answer
> 2 votes
One solution might be to create a custom field for participants with check boxes for each day. Then you could record attendance without having multiple events. You could use the Batch Update via Profile feature to make recording attendance easier for you staff.

Not sure how many events or exact setup. If you use a generic field labels (Day 1, Day 2, Day 3, etc.) you could re-use the custom field and not have to create ones for each event.

Hope this helps.

---
Tags: civievent
---


title: all imports seem to geo code

text:
# Question
Title: all imports seem to geo code
I never check the geocode box when importing. Yet, I found that even small imports were taking a long time. I ran strace on the php process and saw lots of lookups to google. So I disabled both the mapping provider and geocoding provider globally, re-ran the import and it went through in a fraction of the time.

Next, I took a closer look at the code that is triggered based on the geo coding checkbox:

The file: Contact/Import/Parser/Contact.php contains:

```
 public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) {
    $config = CRM_Core_Config::singleton();
    $this->_unparsedStreetAddressContacts = array();
    if (!$doGeocodeAddress) {
      // CRM-5854, reset the geocode method to null to prevent geocoding
      $config->geocodeMethod = NULL;
    }

```

In other words, if geo code checkbox is unchecked, the $doGeocodeAddress is set to false. If it is set to false, then we set `$config->geocodeMethod = NULL;`

Hm. Could this possibly work? If you set a property on a singleton locally in a function, it seems like it would not be available outside the function.

However, this "fix" has been in place for years so I'm asking this question as a sanity check before opening a ticket.

Maybe something changed in the behavior of PHP?

# Answer
> 1 votes
The answer is bug, but not for the reasons I thought.

In short: the addition of MagicMerge seems to be the culprit, resulting in changed behavior when geocodeMethod is set to NULL.

Long answer:

First, setting the property of a singleton in one function, does result in it persisting even in other functions. The singleton really does act like a global variable. That's how this has worked all the way up to 4.7.

However, in 4.7 MagicMerge was introduced to streamline the configuration object.

This approach added \__get and \__set functions to handle properties that are not defined.

Now, if a property (like geocodeMethod) is set, it is added to the cache (`$this->cache[$name] = $v;`). So far so good.

However, when it is retrieved, it only comes from the cache if it is set:

```
if (isset($this->cache[$k])) {
  return $this->cache[$k];
}

```

Oops. If we set it to NULL it will never be retrieved from the cache and will always be retrieved using the function `CRM_Utils_Geocode::getProviderClass`

---
Tags: import, geocoding
---


# Question
Title: Correct location of civicrm.settings.php in CiviCRM 4.7 for WordPress
I've got a WordPress site here (CiviCRM 4.7.17, upgraded recently from 4.7.15) which has two different civicrm.settings.php files:

1. wp-content/plugins/civicrm/civicrm.settings.php
2. wp-content/uploads/civicrm/civicrm.settings.php

File #1 contains the correct settings, and files #2 appears to have outdated settings.

Questions:

* Which is the correct path in CiviCRM 4.7?
* Can I just delete the one with the wrong path (after I ensure the correct one is in the right place)?
* Is the whole directory wp-content/{uploads,plugins}/civicrm in the same boat -- that is, is just one of them needed, and if so, what's the correct path for that directory?

# Answer
> 3 votes
The recommended location is `wp-content/uploads/civicrm/civicrm.settings.php`.

The deprecated location, still supported as of April 2017, was `wp-content/plugins/civicrm/civicrm.settings.php`, but this is both easy to break on upgrade ("whoops, I removed the old plugin and the settings files, and I don't have backups!") and on some sites is not a writeable location (where people prefer to not have WordPress able to modify its own codebase).

This can be seen in `civicrm-wordpress/civicrm.php` at line 103 and is documented in CRM-16408. Code docs refer to this as "the 4.6 and prior location" so I guess that tells us it's new to 4.7.

It looks like this was applied to all the related files, a WP site I set up the other day had everything in `wp-content/uploads` AFAICT, which seems like an improvement.

However, I noticed that `civicrm.php` looks like it gives preference to the deprecated location. IDK if there is a specific reason to this - it feels like it might set up a surprise for some sites if that behaviour ever changes?

---
Tags: wordpress, 4.7, civicrm.settings.php
---


title: Searching for SMS Campaigns

text:
# Question
Title: Searching for SMS Campaigns
I am unable to search Campaigns in my sent SMS's. It appears that the field for searching archive SMS's via campaign has disappeared

# Answer
> 1 votes
It appears that there was a JS conflict with WPMU custom sidebars after an update to the Word Press plugin. The file was wpmu-ui.3.min.js under Word Press 4.7.3.

---
Tags: sms
---


# Question
Title: Managing a smart mailing groups (un)subscriptions
According to https://docs.civicrm.org/user/en/4.6/organising-your-data/smart-groups/

> Smart groups respect people's subscription preferences. If people unsubscribe from the newsletter, they will be removed from the smart group.

Are there ways to

* see who unsubscribed from smart groups
* manually unsubscribe members as an admin

# Answer
On the manage group screen (civicrm/group?reset=1) click on contacts next to the group in question. There you should be able to search for added pending and removed contacts for this particular group.
> 2 votes

---
Tags: smartgroups, mailing, administer
---


# Question
Title: Record payment for event registration in CiviCRM 4.7.16
We've recently upgraded to CiviCRM 4.7.16. I need to record a payment for an event registration. I used to go to the event record, click edit, and then there would be an option to record a payment. Now, that option does not seem to exist. When I add a new event participant, there is also no opportunity to record a payment. Anyone know how I can record a payment?

# Answer
> 1 votes
I think i replicated this on Demo, but only if the Event was not set to be a Paid Event at civicrm/event/manage/fee?reset=1&action=update&id=x

As soon as i made it a Paid Event, the Record Payment option appeared when editing an Event Registration

# Answer
> 0 votes
Has there been any resolution on this?

I am seeing this same behavior: a paid event, when registering through the backend, I do not get the option to record payment (I'm using a price set).

Running 4.7.15 in WP.

Note 1: I also do not get the selected profile with custom fields. Note 2: This is for a past event (don't know if that matters)

---
Tags: civievent
---


# Question
Title: Random 9002 Errors from iATS when making donations
WordPress 4.6.26 Civi 4.7.3 iATS for Payment Processing

Beginning in Jan we started hearing from donors that when they set up donations they would get a 9002 Error when they clicked Confirm. So far it appears to be ACH transactions that are having trouble.

The iATS Request Log for these donations looks the same as all others. However, the iATS Response Log does not have anything in the auth\_result field.

The first time this happened, I attempted entering the donor's account info for them and got the same results. 20 minutes later it went through with no error.

The other cases have processed the first attempt for me but I can see in the Response Log that they tried several times with no auth\_results data. I have another one right now that the donor tried 2 days in a row and got the 9002 Error. I have not tried to do it yet because I was hoping to do some trouble shooting first.

At least two of the donors were using Google Chrome for their browser. I have not seen any problems with any browsers except IE.

How to get IATS working It is about someone else getting the 9002 Error (but theirs was constant). I changed to Karin's https://www2.iatspayments.com/NetGate/ProcessLinkv2.asmx?WSDL and donations are still processing. Just for clarification, does any one know: 1. What are the special characters to avoid? 2. Is this in our password with iATS/Civi or is this in the donor's password? 3. Is there a list of potential "misconfiguration" issues out there somewhere that I can go over?

Does anyone have any other ideas for troubleshooting the sporadic loss in communications? Are there other logs that would show if Civi actually sent the request or that show if iATS received the request?

# Answer
> 0 votes
I think we found the problem(s). We connected with Trustwave and they have a PCI compliance scan. I ran the scan on our website and it revealed some issues. We worked with our web-host to correct those server setup issues. We re-ran the scan and the issues were gone.

As Karin said, intermittent issues are hard to track. But we had one donor who always got the 9002 error (we tried it after every "fix"). After passing the Trustwave PCI scan, I tried the "consistently failing" donation again and it went through no problem.

Even if everyone (web-host, payment processor, etc) says they are PCI compliant, I would suggest you run a compliance scan to be sure. If nothing else, it can be a great troubleshooting tool for an intermittent processing issue.

# Answer
> 0 votes
Intermittent issues can be difficult to diagnose. A couple of notes that may help:

What you really need to do is to get TLS 1.2 and switch back to the www server. The www2 server is only needed for those not at the TLS 1.2 standard yet and is going to go away. Your lack of TLS 1.2 is probably a symptom of a system that is not up to date or maintained, that could well be the key issue.

Avoid any special characters in your iATS 80 account password; If you're using another than 80 account w/ iATS then confirm with customer services that you can deposit monies into that account via WebServices. If you're using more than one iATS subaccount 80, 81, 82 etc confirm all are able to accept monies via WebServices.

---
Tags: error, iats
---


# Question
Title: is there any way to restrict data export?
Is there any way to restrict data export while still allowing users to see all data? I still want to give this permission '*View ANY CONTACT in the CiviCRM database, export contact info and perform activities such as Send Email, Phone Call, etc*.' but don't want them to be able to export the contacts. civi 4.6.11, drupal 7

# Answer
> 9 votes
Yes, it is now possible. I didn't hear from Kboy so I wrote an extension myself:

https://github.com/progressivetech/net.ourpowerbase.exportpermission

# Answer
> 1 votes
No it's not possible as far as i know.

Your best chance is to create an extension that will :

1. remove export actions from the menu after a search if the user doesn't have enough permission by using hook\_civicrm\_searchTasks : https://wiki.civicrm.org/confluence/display/CRMDOC/hook\_civicrm\_searchTasks
2. remove the export buttons from reports also. I guess you could do it by creating a alternative version of CRM/Report/Form/Actions.tpl that will check for the permissions before displaying the buttons. Yet, it still a display only hack and you might want to change CRM/Report/Form.php to ignore outputMode = csv...

---
Tags: contacts, permissions, export
---


# Question
Title: Append an option to the BlockSchedule Directive in crmMailing
I'm making a first foray into customizing the mailing compose screen.

I want to add a third option to the options in BlockSchedule.html (schedule.mode = regular) which will open up a few more options to allow you to send mailings on a regular basis.

The template code I want to add is along the lines of

```
<div>
  <input ng-model="schedule.mode" type="radio" name="send" value="recur" id="schedule-send-recur"/>
  <label for="schedule-send-recur">{{ts('Send on a regular basis')}}</label>
</div>

```

Selecting this will open up a new directive with options for sending on a regular basis. It will also swap the submit mailing button for a schedule mailings button and possibly do other stuff.

But right now, I am stuck on a good way to add this option.

This answer (adapted below) makes me think that something along the lines of the following would work, but what do I do with the directive at this point?!

```
angular.module('crmMailing').config(function($provide){
   // intercept crmMailingBlockMailing directive, note the 'Directive' suffix
   $provide.decorator('crmMailingBlockScheduleDirective', function($delegate){
        var directive = $delegate[0];

```

# Answer
What you want to do now is *decorate* the directive ;)

The decorator method allows you to *decorate/modify* an angular directive/service/factory/controller before its usage/instantiated.

You have two options (that I know of) to manipulate the directives DOM, one is the compile function, used for template DOM manipulation (is where the template is actually compiled), and the second is the link function, is where the data/scope is attached to the instantiated element/elements, and usaully used for event listeneres, like $watch

The angular mailing app uses a boilerplate template to declare directives, see the source here.

I'll try to explain with inline comments:

```
angular.module( 'crmMailing' ).config( function( $provide ){

        // the callback recieves the directive when the Mailing app bootsraps
        $provide.decorator( 'crmMailingBlockScheduleDirective', function( $delegate ){

            // $delegate is an array, we grab and store the directive into the 'directive' variable
            var directive = $delegate[0];

            // we hold the original link function
            var link = directive.link;

            // as the link function is already defined in Civi's boilerplate
            // we create the compile function and return a new link function calling apply on the old link function
            directive.compile = function( Element, Attrs ){

                // you can manipulate the directive's template here, like adding your own DOM elements/directives
                Element.append( '<h1>Text added from compile</h1>' );

                // return new link function
                return function( scope, elem, attr ){

                    // call apply to get original functionality
                    link.apply( this, arguments );

                    // add new functionality here
                    elem.append( '<h1>Text added from new link function</h1>' );

                };
            };

            // always return $delegate
            return $delegate;
        });
    });

```

In order for this to work what I do is declare a fake/empty angular module like `crmMailSubjectReview = angular.module( 'crmMailSubjectReview', [] );`, load it via `hook_civicrm_angularModules` and then add the `crmMailing` config block, see here another small example (have a look at the comments to see the template and the end result).
> 1 votes

---
Tags: civimail, developer, angular
---


# Question
Title: Problems with first test site using Civicrm buildkit
hope there is someone who can help? It's taken me a couple of days, but I've finally got the buildkit successfully installed, however when I try to create my first instance I'm getting permissions errors, is this because I've installed it in the wrong place? I've checked the Apache version and the restart command.

This is a fresh install on gc ubuntu16.04 with up to date dependencies

Errors:

`seankenny@instance-2:~$ ./buildkit/bin/amp test
Create test application
Create data directory: /home/seankenny/.amp/canary/data/F2Dn7Skcr6zJM61SvzEB72IjOuoUMHwi
AMP_URL='http://localhost:7979'
AMP_ROOT='/home/seankenny/.amp/canary'
AMP_DB_DSN='mysql://canary_wfa83:n29ZlTuwvd9UxLuI@127.0.0.1:3306/canary_wfa83?new_link=true'
AMP_DB_USER='canary_wfa83'
AMP_DB_PASS='n29ZlTuwvd9UxLuI'
AMP_DB_HOST='127.0.0.1'
AMP_DB_PORT='3306'
AMP_DB_NAME='canary_wfa83'
AMP_DB_ARGS='--defaults-file='\''/home/seankenny/.amp/my.cnf.d/my.cnf-e7cb970bf21e2d4b82d944711b5fc15b'\'' canary_wfa83'
Connect to test application
Expect response: "response-code-wgnXWegrsL"
PHP Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: Connection refused in phar:///home/seankenny/buildkit/bin/amp/src/Amp/Command/TestCommand.php on line 163
Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: Connection refused in phar:///home/seankenny/buildkit/bin/amp/src/Amp/Command/TestCommand.php on line 163
Received incorrect response: ""
Tips for common issues:
 - (Re)run "amp config"
 - Double-check the httpd_type (apache24) along with any displayed instructions.
 - Double-check the httpd_restart_command.
 - (Re)run "amp test"`

# Answer
Accessing URL `http://localhost:7979` requires at least these things:

* Your client is able to resolve host `localhost` to the local IP address
* You have a server which is listening to port 7979
* Your server on port 7979 is able to listen to that port (not firewalled / filtered)

### Check DNS for localhost

If the command `host localhost` does not resolve to 127.0.0.1, you should check your `/etc/hosts` file has an entry which defines the correct IP for localhost.

Expected output is something like:

```
chris@strike:~$ host localhost
localhost has address 127.0.0.1
localhost has IPv6 address ::1

```

### Check server is listening on expected port

From the debug output above, we can see your server expects to bind to port 7979. So we can use `lsof` to confirm that the expected process is listening on this port.

```
chris@strike:~ $ sudo lsof -i :7979
COMMAND   PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
nginx     432 chris    6u  IPv4 0x74beb77a214bedc1      0t0  TCP *:micromuse-ncps (LISTEN)
nginx   12446 chris    6u  IPv4 0x74beb77a214bedc1      0t0  TCP *:micromuse-ncps (LISTEN)
nginx   12447 chris    6u  IPv4 0x74beb77a214bedc1      0t0  TCP *:micromuse-ncps (LISTEN)

```

This output tells us that port 7979 "belongs" to a service named "micromuse-ncps", but we'll ignore that; we're using that port for your AMP hosts. Just read "micromuse-ncps" as saying "7979".

Your output should show that -

* The expected program has this port bound. (I'm using nginx, you'll see apache there.)
* The expected user account is running this program. (If I saw "alice" instead of "chris" as the username, that might be telling me that Alice's buildkit had already claimed port 7979, so I couldn't have it.)
* If no results show up, this might indicate that your webserver didn't know to bind that port, which might happen if the AMP include was not added to the webserver's config file.

### Firewalls

If the port is bound but you can't connect to it, that might indicate the presence of a firewall or other system preventing AMP's test connecting.

Documenting firewall configuration isn't in scope here, sorry! Should your buildkit host have a firewall, you'll have to be responsible for making sure that firewall doesn't interfere with buildkit, by ensuring the buildkit/amp ports are available to the expected client IPs.
> 4 votes

# Answer
I have buildkit working in multiple places but a quick check suggests that

./buildkit/bin/amp test

gives the results above - so I don't know if you have to get past that to get buildkit working...

Probably only if you want it to run on a port as opposed to defining something in your hosts file
> 0 votes

---
Tags: permissions, civicrm-buildkit
---


title: Participant wants to cancel Event

text:
# Question
Title: Participant wants to cancel Event
I have a customer who wants to send a hashed link in an e-mail reply (or anything else that will do the trick) to a participant so that they can cancel their registration for an event without having to phone or send an e-mail. We use profiles in the Events. We use CivicRM 4.6.12

# Answer
I don't think This functionality exists yet.

See: https://wiki.civicrm.org/confluence/display/CRM/Self+service+view,+update+and+cancel+for+CiviEvent+and+improvements+to+event+badges
> 2 votes

# Answer
I know this is over a year old, but I think it deserves an update. In 4.7, functionality has been added to allow for user self-service cancelation. When enabled for an Event (on the online registration tab), it sends a cancel or transfer link in the confirmation email. See https://issues.civicrm.org/jira/browse/CRM-16761
> 4 votes

---
Tags: civievent, profile
---


# Question
Title: How do I display the Contact ID on User Dashboard?
MAYYYBE I am over complicating this, but I have searched and searched and only found this answered for Drupal.

We are on Wordpress and would like for members to provide me with a searchable unique id. Obviously, that means the Contact ID would be best. I am just struggling with an easy way to integrate this SINGLE piece of info into the user dashboard.

I really just want it to say something like: Your Contact ID is: ### at the top of the dashboard so people aren't freaked out by looking for it.

# Answer
There are a couple ways you could do this:

Create a report that shows the contact ID and name, make that report available on a user dashboard, then you can use the dashlet extension to place the dashlet on the end-user dashboard.

Take the Contact IDs and reimport them as the External ID, then display that in the Contact Dashboard as part of the member profile.

Write some code to pull the ID out of the database and display it graphically as part of a Membership Card. I do this on one of my Joomla sites but there's no reason why it can't work in Wordpress.

Example:
> 2 votes

---
Tags: wordpress, dashboard, user-dashboard, contact-reference
---


# Question
Title: Search in Manage Groups renders "contacts" link as editable under "visibility column"
CiviCRM 4.7.17. It should be noted that we upgraded from the latest LTS about 2 weeks ago. On Drupal 7.x

Is this a Civi bug, or a theme bug?

1. Before we search for a group.

2. After we search for a group

3. When we click 'Contacts' we see Group Visibility as editable choice

# Answer
The screenshots also show you have names in the 'Count' column and a 'mailchimp sync' column which is not standard. If you disable the mailchimp extension, or whatever else is changing that results display, do you get the same issues?
> 1 votes

---
Tags: groups, theme
---


# Question
Title: Public CiviCRM forms not working for anonymous users
Public CiviCRM forms (contribution pages, registration for events, mailing subscriptions, etc.) works for logged users but when we try to use for anonymous users they don't work.

For example, if we submit a registration for event the form redirects to itself without any error message.

We run CiviCRM over Drupal 7.

# Answer
After a long frustrating debugging I found the answer on this two pages:

Installation and Configuration Troubleshooting

Anonymous Users Cannot Contribute

> For Drupal sites, ensure that uid = 0 exists in your Drupal users table. This is required for anonymous access to CiviCRM pages and forms to work properly.
> 4 votes

---
Tags: drupal, forms, user
---


# Question
Title: What is the best way to create a conditional question in case activities?
I currently have cases with different activities in CiviCRM for different programs. I then used custom fields to add additional questions to appear in each activity in the forms. Is it possible to set conditional questions to appear based on a prior question?

P.S. I'm currently using CiviCRM on Drupal. However, I like to keep using the case activities form instead of a Webform for the cases.

# Answer
> 2 votes
CiviCRM does not have a built-in way to create conditional fields in its forms. You mentioned Drupal Webforms and yes they could solve that problem for you if you were open to using a webform instead.

Otherwise the only solution is to learn to write jQuery code and customize your form by showing/hiding fields with javascript.

---
Tags: drupal, civicase, condition
---


# Question
Title: Is it possible to segment data so only users can see certain information?
Example: our org has 11 Networks that are geographic (E.g. Europe, Latin America etc). Would it be possible to configure CiviCRM so only staff within our Europe network could see records (contact details, financial details etc) within their network?

# Answer
There is also a Permissioned Relationship approach that can work well for multilayered organisations using this Fuzion extension
> 1 votes

# Answer
Yes, you can do that. Read up on CiviCRM Access Control to get started.
> 5 votes

---
Tags: civimember
---


# Question
Title: Fatal error when including certain custom fields in Activity Report
I noticed that a couple of our reports had broken after the update to 4.7 (on Drupal), and trying to recreate the reports brings up the same error, with a message saying 'DB Error: no such field'

Mostly the activity report works fine, and most of the reports involving custom data are okay, but there's one particular custom data set that generates a fatal error. We're also using the Extended Reports extension, and the Activity reports from that don't have a problem with this data set.

From the error log (this is for just one custom field selected, but I get similar errors for other or multiple fields):

```
Feb 12 11:07:08  [info] $Fatal Error Details = Array
(
[callback] => Array
    (
        [0] => CRM_Core_Error
        [1] => handle
    )

[code] => -19
[message] => DB Error: no such field
[mode] => 16
[debug_info] => CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
SELECT civicrm_contact_target.sort_name as civicrm_contact_contact_target, civicrm_contact_target.id as civicrm_contact_contact_target_id, activity_civireport.id as civicrm_activity_id, activity_civireport.source_record_id as civicrm_activity_source_record_id, activity_civireport.activity_type_id as civicrm_activity_activity_type_id, activity_civireport.subject as civicrm_activity_activity_subject, activity_civireport.activity_date_time as civicrm_activity_activity_date_time, activity_civireport.status_id as civicrm_activity_status_id, address_civireport.country_id as civicrm_address_country_id, value_gwl_hears_me_equal_opps_form_33_civireport.what_is_your_postcode__179 as civicrm_value_gwl_hears_me_equal_opps_form_33_custom_179, address_civireport.street_name as civicrm_address_street_name, address_civireport.street_number as civicrm_address_street_number, address_civireport.street_address as civicrm_address_street_address, address_civireport.city as civicrm_address_city, address_civireport.postal_code as civicrm_address_postal_code
    FROM civicrm_activity activity_civireport
         INNER JOIN civicrm_activity_contact  activity_contact_civireport
                ON activity_civireport.id = activity_contact_civireport.activity_id AND
                   activity_contact_civireport.record_type_id = 3
         INNER JOIN civicrm_contact civicrm_contact_target
                ON activity_contact_civireport.contact_id = civicrm_contact_target.id

             LEFT JOIN civicrm_address address_civireport
                       ON (civicrm_contact_target.id =
                           address_civireport.contact_id) AND
                           address_civireport.is_primary = 1
  WHERE activity_civireport.is_test = 0 AND
                            activity_civireport.is_deleted = 0 AND
                            activity_civireport.is_current_revision = 1 AND ( activity_civireport.activity_type_id IN (23) )  [nativecode=1054 ** Unknown column 'value_gwl_hears_me_equal_opps_form_33_civireport.what_is_your_postcode__179' in 'field list']
[type] => DB_Error
[user_info] => CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
SELECT civicrm_contact_target.sort_name as civicrm_contact_contact_target, civicrm_contact_target.id as civicrm_contact_contact_target_id, activity_civireport.id as civicrm_activity_id, activity_civireport.source_record_id as civicrm_activity_source_record_id, activity_civireport.activity_type_id as civicrm_activity_activity_type_id, activity_civireport.subject as civicrm_activity_activity_subject, activity_civireport.activity_date_time as civicrm_activity_activity_date_time, activity_civireport.status_id as civicrm_activity_status_id, address_civireport.country_id as civicrm_address_country_id, value_gwl_hears_me_equal_opps_form_33_civireport.what_is_your_postcode__179 as civicrm_value_gwl_hears_me_equal_opps_form_33_custom_179, address_civireport.street_name as civicrm_address_street_name, address_civireport.street_number as civicrm_address_street_number, address_civireport.street_address as civicrm_address_street_address, address_civireport.city as civicrm_address_city, address_civireport.postal_code as civicrm_address_postal_code
    FROM civicrm_activity activity_civireport
         INNER JOIN civicrm_activity_contact  activity_contact_civireport
                ON activity_civireport.id = activity_contact_civireport.activity_id AND
                   activity_contact_civireport.record_type_id = 3
         INNER JOIN civicrm_contact civicrm_contact_target
                ON activity_contact_civireport.contact_id = civicrm_contact_target.id

             LEFT JOIN civicrm_address address_civireport
                       ON (civicrm_contact_target.id =
                           address_civireport.contact_id) AND
                           address_civireport.is_primary = 1
  WHERE activity_civireport.is_test = 0 AND
                            activity_civireport.is_deleted = 0 AND
                            activity_civireport.is_current_revision = 1 AND ( activity_civireport.activity_type_id IN (23) )  [nativecode=1054 ** Unknown column 'value_gwl_hears_me_equal_opps_form_33_civireport.what_is_your_postcode__179' in 'field list']
[to_string] => [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::handle prefix="" info="CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
SELECT civicrm_contact_target.sort_name as civicrm_contact_contact_target, civicrm_contact_target.id as civicrm_contact_contact_target_id, activity_civireport.id as civicrm_activity_id, activity_civireport.source_record_id as civicrm_activity_source_record_id, activity_civireport.activity_type_id as civicrm_activity_activity_type_id, activity_civireport.subject as civicrm_activity_activity_subject, activity_civireport.activity_date_time as civicrm_activity_activity_date_time, activity_civireport.status_id as civicrm_activity_status_id, address_civireport.country_id as civicrm_address_country_id, value_gwl_hears_me_equal_opps_form_33_civireport.what_is_your_postcode__179 as civicrm_value_gwl_hears_me_equal_opps_form_33_custom_179, address_civireport.street_name as civicrm_address_street_name, address_civireport.street_number as civicrm_address_street_number, address_civireport.street_address as civicrm_address_street_address, address_civireport.city as civicrm_address_city, address_civireport.postal_code as civicrm_address_postal_code
    FROM civicrm_activity activity_civireport
         INNER JOIN civicrm_activity_contact  activity_contact_civireport
                ON activity_civireport.id = activity_contact_civireport.activity_id AND
                   activity_contact_civireport.record_type_id = 3
         INNER JOIN civicrm_contact civicrm_contact_target
                ON activity_contact_civireport.contact_id = civicrm_contact_target.id

             LEFT JOIN civicrm_address address_civireport
                       ON (civicrm_contact_target.id =
                           address_civireport.contact_id) AND
                           address_civireport.is_primary = 1
  WHERE activity_civireport.is_test = 0 AND
                            activity_civireport.is_deleted = 0 AND
                            activity_civireport.is_current_revision = 1 AND ( activity_civireport.activity_type_id IN (23) )  [nativecode=1054 ** Unknown column 'value_gwl_hears_me_equal_opps_form_33_civireport.what_is_your_postcode__179' in 'field list']"]
)

Feb 12 11:07:08  [info] $backTrace = #0 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\Error.php(235): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
#2 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#3 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\DB.php(976): PEAR_Error->PEAR_Error("DB Error: no such field", -19, 16, (Array:2), "CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...")
#4 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\PEAR.php(564): DB_Error->DB_Error(-19, 16, (Array:2), "CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...")
#5 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\DB\common.php(1905): PEAR->raiseError(NULL, -19, NULL, NULL, "CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...", "DB_Error", TRUE)
#6 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\DB\mysql.php(895): DB_common->raiseError(-19, NULL, NULL, NULL, "1054 ** Unknown column 'value_gwl_hears_me_equal_opps_form_33_civireport.what...")
#7 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\DB\mysql.php(328): DB_mysql->mysqlRaiseError()
#8 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\DB\common.php(1216): DB_mysql->simpleQuery("CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...")
#9 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\DB\DataObject.php(2435): DB_common->query("CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...")
#10 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\DB\DataObject.php(1627): DB_DataObject->_query("CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...")
#11 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\DAO.php(334): DB_DataObject->query("CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...")
#12 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\DAO.php(1209): CRM_Core_DAO->query("CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...", TRUE)
#13 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Report\Form\Activity.php(775): CRM_Core_DAO::executeQuery("CREATE TEMPORARY TABLE civireport_activity_temp_target CHARACTER SET utf8 COL...")
#14 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\Form.php(423): CRM_Report_Form_Activity->postProcess()
#15 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\QuickForm\Action\Submit.php(74): CRM_Core_Form->mainProcess()
#16 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\HTML\QuickForm\Controller.php(203): CRM_Core_QuickForm_Action_Submit->perform(Object(CRM_Report_Form_Activity), "submit")
#17 C:\xampper\htdocs\able\sites\all\modules\civicrm\packages\HTML\QuickForm\Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Report_Form_Activity), "submit")
#18 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\Controller.php(351): HTML_QuickForm_Page->handle("submit")
#19 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Utils\Wrapper.php(113): CRM_Core_Controller->run()
#20 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Report\Page\Report.php(72): CRM_Utils_Wrapper->run("CRM_Report_Form_Activity", NULL, NULL)
#21 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\Invoke.php(312): CRM_Report_Page_Report->run((Array:3), NULL)
#22 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\Invoke.php(86): CRM_Core_Invoke::runItem((Array:14))
#23 C:\xampper\htdocs\able\sites\all\modules\civicrm\CRM\Core\Invoke.php(54): CRM_Core_Invoke::_invoke((Array:3))
#24 C:\xampper\htdocs\able\sites\all\modules\civicrm\drupal\civicrm.module(454): CRM_Core_Invoke::invoke((Array:3))
#25 [internal function](): civicrm_invoke("report", "activity")
#26 C:\xampper\htdocs\able\includes\menu.inc(527): call_user_func_array("civicrm_invoke", (Array:2))
#27 C:\xampper\htdocs\able\index.php(21): menu_execute_active_handler()
#28 {main}

```

(Just double-checked, and I'm also unable to filter the Activity Report with these custom fields)

# Answer
I think the isssue might be based on the lenght of the table name of field name\> I recollect we had an issue with that quite some time ago
> 1 votes

# Answer
Inspect the DB and see if this table actually exists in your local and (if relevant) upstream DB copies?

If the table doesn't exist locally *only* but does elsewhere, that might point to a failed import or a limitation of your local MySQL environment (eg filename limit on windows MySQL).

If the table doesn't exist at all, perhaps try recreating the custom data group with a shorter name? According to https://stackoverflow.com/q/6868302/43034 the limit is 64 char so this may not be the cause.
> 0 votes

---
Tags: custom-fields, civireport, activities
---


title: mail Fetch Bounces errors

text:
# Question
Title: mail Fetch Bounces errors
I have got everything else working but I get the following error from the Fetch Bounces scheduled job (in the scheduled job log)

> Full message: Finished execution of Fetch Bounces with result: Failure, Error message: A fatal error was triggered: Could not connect to MailStore for return@downham.org.uk@downham.org.uk.mail.aa.net.uk
>
> Error message:
>
> Empty mail protocol

I'm running on WordPress at a hosting provider. I've checked that I can access the mail server from elsewhere, re-entered the data in case of a typo. Tried POP as well as IMAP, with/without SSL. Also tried with Google mail server instead. Finally I tried from one of the Drupal CiviCRM demo servers and it worked from there. I also tried telneting into the IMAP server from the hosting site and that worked fine so can't be a network issue. So it looks like either its a WordPress issue or something about the hosting provider configuration.

Any suggestions as to where to look next?

Many thanks - Mick

# Answer
My sense is that this is more likely to be a hosting/configuration issue than a Wordpress issue. Though it could of course be a hosting issue that only affects Wordpress sites :p. Did you try testing on http://wpmaster.demo.civicrm.org/?

'Empty mail protocol' is from the more helpful end of the error message spectrum.

I would first check on this page civicrm/admin/mailSettings?reset=1 that the **protocol** is set for the processor you are using for **Bounce processing**.

If and when you have ruled out any issues there, it would be time to start digging a little deeper...

---

*Hopefully you don't have to read this far, but just in case...*

Depending on your willingness to jump into the code case, the next step would be to look through the code of the Fetch Bounces scheduled job. https://github.com/civicrm/civicrm-core/blob/master/api/v3/Job.php#L356 passes of to https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/Mail/EmailProcessor.php quite quickly.

It looks like your error message is being generated here: https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/Mail/EmailProcessor.php#L165 and here: https://github.com/civicrm/civicrm-core/blob/master/CRM/Mailing/MailStore.php#L57.

So the question is, why isn't $protocols\[$dao-\>protocol\] set on https://github.com/civicrm/civicrm-core/blob/master/CRM/Mailing/MailStore.php#L56?

Happy to expand on this answer if necessary.
> 2 votes

---
Tags: email
---


# Question
Title: Is upgrade possible for `payment` type Extension?
I see extension of type 'payment' has been deprecated and hence not listed in the active modules we get from `getActiveModuleFiles()` function. Due to this, any upgrade to this ext. is not possible since the upgrade link is not shown for them (as they are not active modules anymore)

Is there any way to upgrade such extentions - i.e to execute the following query in upgrade?

```
UPDATE civicrm_extension
SET type = "module"
WHERE full_name = "nz.co.fuzion.paystation

```

I haven't found anything other than the answer I posted below.

# Answer

> 1 votes

---
Tags: extension, payment-processor, developer, payment
---


title: Undo a Deletion on an activity

text:
# Question
Title: Undo a Deletion on an activity
I deleted an activity and would like to re-add it. Please help! I can't seem to find a search bar that would help me find the right steps to correct.

# Answer
> 1 votes
I don't think you will find a process to undelete a deleted activity via the UI. If you have access to the database then you could try finding the relevant entry from the log\_civicrm\_activity and log\_civicrm\_activity\_contact to reconstruct your missing item.

---
Tags: activity
---


# Question
Title: Autocomplete Contact Search - Add Contact ID possible?
I'm working with a direct mail company on a donation campaign. They plan on including the contact ID on the top of the donation tear off. Then when we manually enter the donation we're be able to search by contact ID, avoiding possible duplicates. This is the way they always do it for efficiency.

There's several you can already add under "Search Preferences" but not the contact ID.

Is it possible to just manually add it to the database?

# morekidsonbikes

# Answer
> 1 votes
I needed to do something similar. There were two things to work on: getting the Contact ID in the search suggestion in the quick search and getting CiviCRM to search the Contact Id by default when placing a number in the quick/regular search and hitting enter.

*Note: I just adapted my code to work with contact ID, didn't test it.*

I used a CiviCRM extension with the queryObjects hook:

**\[myext\]/myext.php**

```
// Get the Contact ID to display in the suggestions
function extname_civicrm_apiWrappers(&$wrappers, $apiRequest) {
   if ($apiRequest['entity'] == 'Contact') {
      if ($apiRequest['action'] == 'getquick') {
          $wrappers[] = new CRM_Extname_APIWrapper_GetQuick();
      }
  }
}

function emulate_civicrm_api3_contact_getList($params) {

    $res = civicrm_api3('Contact','get', $params);

    // reformat the output to look like getquick
    foreach ($res['values'] as $idx => &$value) {
        $value['data'] = $value['id'].' :: '.$value['sort_name'] . ( empty($value['nick_name']) ? '' : ' ('.$value['nick_name'].')' );
        foreach (['street_address','city','state_province_name','postal_code','phone','email'] as $col) {
            if (!empty($value[$col])) $value['data'] .= ' :: '.$value[$col];
        }
    }

    return $res;
}

// Get the id to be part of the default search
function extname_civicrm_queryObjects (&$queryObjects, $type = 'Contact') {
    if ($type == 'Contact') {
        $queryObjects[] = new CRM_Extname_BAO_Query();
    }
}

```

**\[myext\]/CRM/Extname/APIWrapper/GetQuick.php** clas

```
s CRM_Extname_APIWrapper_GetQuick implements API_Wrapper {

  public function fromApiInput($apiRequest) {

        if (!empty($apiRequest['params']['field_name'])) return $apiRequest;

        $apiRequest['entity'] = 'Contact';
        $apiRequest['action'] = 'getlist';
        $apiRequest['function'] = 'emulate_civicrm_api3_contact_getList';

        $apiRequest['params']['sequential'] = '1';
        $apiRequest['params']['nick_name'] = $apiRequest['params']['id'] = $apiRequest['params']['name'];

        unset($apiRequest['params']['name']);
        unset($apiRequest['params']['option']);
        unset($apiRequest['params']['task']);
        unset($apiRequest['params']['field_name']);
        unset($apiRequest['params']['table_name']);

        return $apiRequest;
  }

  // this never seems called
  public function toApiOutput($apiRequest, $result) {

      return $result;
  }

}

```

**\[myext\]/CRM/Extname/BAO/Query.php**

```
class CRM_Extname_BAO_Query extends CRM_Contact_BAO_Query_Interface {

    function &getFields() {
        return ['id'];
    }

    function from($name, $mode, $side) {
        return '';
    }

    function where(&$query) {

        $grouping = NULL;
        foreach (array_keys($query->_params) as $id) {
            if (empty($query->_params[$id][0])) {
                continue;
            }

            $this->whereClauseSingle($query->_params[$id], $query);
        }

    }

    function whereClauseSingle(&$values, &$query) {
        list($name, $op, $value, $grouping, $wildcard) = $values;

        $fields = $this->getFields();
        if (!empty($value) && !is_array($value)) {
          $quoteValue = "\"$value\"";
        }

        // Look in CRM_Contact_BAO_Query:2025 for how this is all gatherered into or's and ands

        switch ($name) {
          case 'sort_name':
            // the default search is grouping=0; this is pretty hard coded into CRM_Contact_BAO_Query
            if ($grouping==0) {
                foreach ($query->_where[$grouping] as $key => $val) {
                    if (strpos($query->_where[$grouping][$key],'sort_name')===false) continue;
                    // search id if numeric
                    if (is_numeric($value)) {
                        $query->_qill[$grouping][$key] .= ' Or '.($value ? ts('Contact ID is '.$quoteValue) : ts('Contact ID is not '.$quoteValue));
                        $query->_where[$grouping][$key] .= ' OR '.CRM_Contact_BAO_Query::buildClause("contact_a.id", "=", (int)$value, "Int");
                    }
                    break;
                }
            }
            return;
        }

    }

    public function getPanesMapper(&$panes) {

        return $panes;
    }

}

```

# Answer
> 0 votes
It helps if you mention the version you are on. In the Quick Search you should be able to see a setting when you click in there, to use Internal ID, then you can just enter the ID.

Personally I would make it even simpler if you have been sent a spreadsheet, or can get their data in a spreadsheet, and use the CONCATENATE function in your spreadsheet so you have a link from there to go directly to a link this this civicrm/contact/view/contribution?reset=1&action=add&cid=XXX&context=contribution where XXX is the Internal ID

# Answer
> 0 votes
You can add the contributions using Contact ID via the Import interface. Create a csv file with the contribution info and import it.

But for the long term, I think this would be a brilliant addition to the New Contribution \> Select Contact or Batch Entry \> Select Contact search parameters. When people mail a check, our paper receipts have a tear off portion at that bottom that they can use with their next contribution. We could have it print their Contact ID in that lower section and use it when doing the data entry just as Doug described and it should save on selecting the wrong donor with a similar name (or we have some with the same name).

---
Tags: contributions, search
---


# Question
Title: Migrating Drupal Users and CiviCRM Data to New Website
We are building a new Drupal 7 website but have an existing one with some deprecated features and custom code that we no longer wish to salvage for various reasons. I have established the new Drupal site and installed the same version of CiviCRM that we are using currently. The new site has the same CiviCRM configurations, extensions and integration modules and I am ready to import the CiviCRM database into it, which is no issue.

The next step is to finish setting up the new Drupal site and import the users from the old site. Once the users are migrated into the new site, I will re-sync the user accounts with CiviCRM.

What I want to know is, how does CiviCRM determine which contact record to sync the Drupal account with and what does it do in the case of duplicates? I need to make sure membership access is applied correctly to the same user accounts.

# Answer
> 2 votes
Glad it worked! CiviCRM uses the civicrm\_uf\_match table to store the Drupal ID in the column uf\_id (user framework id) and also the CiviCRM contact\_id.

# Answer
> 1 votes
I used MySQL commands to migrate the user tables from Drupal and the whole CiviCRM database and when I re-synced the users, they matched up the same way because the data, such as the UID, wasn't changed.

---
Tags: drupal, civimember, user
---


title: Link State to Country in Custom Fields

text:
# Question
Title: Link State to Country in Custom Fields
Using 4.6, I have a custom field group, and from that group a profile. It includes a State select dropdown and a Country select dropdown.

How would I go about "linking" the Country custom field to the State, so that when I change the country, it reloads the State, filtered by the country?

In older versions, adding the following script snippet with the specific custom field names worked fine, but it doesn't seem to work on 4.6:

```
{literal}
<script language="JavaScript" type="text/javascript">

cj(function()
{

      countryID       = "#custom_122"
      stateProvinceID = "#custom_99"
      callbackURL     = "/civicrm/ajax/jqState"

  cj(countryID).chainSelect(stateProvinceID, callbackURL, null );
});

</script>
{/literal}

```

# Answer
Well, after hunting around on my own, I think I may be able to answer my own question. For others who want to "link" a Profile's custom field Country to a custom field State so that changing the country automatically refreshes the list of States, I was able to do this via the civicrm\_buildForm hook. This hook allows one to modify attributes of specific form elements, and that's all I needed to do.

As of 4.5, I think, the Country/State chaining interaction is done through data-callback and data-target attributes, not through a JS snippet. So, one way to make this work is to add those specific "data-" attributes to the custom fields via the hook.

Here is my example code (apologies for bad formatting). My State field is custom\_99 and my Country field is custom\_122. Once I applied the attributes, my team registration form finally worked as before; changing the Country updates the State list.

```
function xxx_civicrm_buildForm( $formName, &$form )
{
  if ( $formName == 'CRM_Event_Form_Registration_Register' ) {
    // Modify the classes/attributes for country and state fields so the country dropdown will dynamically update the state dropdown
    $form->updateElementAttr('custom_99', array('class' => 'crm-select2 crm-chain-select-target crm-form-select', 'data-callback' => 'civicrm/ajax/jqState', 'data-name' => 'custom_99', 'data-select-prompt' => '- select -', 'data-empty-prompt' => 'Choose country first', 'data-none-prompt' => '- N/A -'));
    $form->updateElementAttr('custom_122', array('class' => 'crm-select2 crm-chain-select-control crm-form-select', 'data-target="custom_99"', 'placeholder' => '- select -'));
...
} // end function

```

By the way, civicrm\_buildForm is a pretty powerful hook, I use it to set defaults and required fields based on the Event Type and values of other custom fields.
> 2 votes

---
Tags: 4.6, templates
---


# Question
Title: Associate state and country fields when not tied to a particular address type
I am building a profile to collect a list of states for various countries a person holds a license in. The states/countries I'm looking for are not associated with any particular address type so I'm not seeing just the states for the selected country like you do normally. It becomes very cumbersome to sort through ALL the states for ALL the countries! Is there a way to tie the state and country fields together?

# Answer
> 1 votes
If I understand your question correctly, I may have just posted an answer to a similar question I had. Hope it helps you.

https://civicrm.stackexchange.com/a/18093/2169

In summary, it's to use the civicrm\_buildForm hook in order to tie your country and state fields together. That will cause the states' list to be refreshed when you choose a country.

# Answer
> 0 votes
Pick the country first. I know with a standard address country is last if at all. Put it first then it should limit the list to the states appropriate to that country.

---
Tags: profile
---


# Question
Title: How to Create webform_civicrm Registrations with: single Ticket vs Table options and Create Contact Records for all Participants
I'm working on setting up an event there are 2 ticket types: individual tickets are $20 each Table of 8 is $130

So a person might purchase 1 ticket at 20 or 2 at 40 or a table of 8 for 130. However many tickets they purchase I need to collect the names.

I'm using Drupal 7 and have webform so that's an option. I've never set up an event like this in Civi so struggling a little bit to make it work.

# Answer
> 4 votes
Definitively a good use case for webform\_civicrm! I've drafted an example for you - here's the screenshots:

1. I always use **webform, webform\_civicrm, webform\_validation** modules
2. In CiviCRM: create Event - **it really needs nothing other than a Type, Role, Title** \- (if needed) a limit on the number of participants; mine is a Public Event (not sure that's needed - but 99% of my Events are public so I made that default); Leave everything else blank (Fees, Online registration tabs - not needed). This is what it looks like:

3. In CiviCRM: make sure you have **a Contribution Page that has a Payment Processor installed that you'd like to use**. It can be a page completely not related to the Fundraising Event.

4. In Webform: View (see below) - **for Transparency I'm showing a lot of fields here that you could hide if you like**:

5. If **you toggle to Five Tickets:** (a Table is $40 -\> so $8/each Participant):

6. **Conditionals are the key thing** in making this happen:

7. **Here's the checkout for a Table:**
8. And **in CiviCRM: 5 Contact Records -\> all Contacts registered as Participants** in the Event:

9. **Things to keep an eye on: Guest Contacts -\> duplicate records;** First Name + Last Name + Email address would be good if using unsupervised rule (no logged in user); You can make your own rule and use that for your Guest Contacts too. What duplicate rules work best for you really depends on your specific CiviCRM;
10. **I typically add relationships** \- easy with webform\_civicrm to give all Guests a Relationship to Primary Contact.
11. UPDATE: **adding in conditionals to show the number of Guests fields:** This properly toggles the fields from Primary Contact + Guest 1 (in case two tickets is selected) to Primary Contact + Guest 1 + 2 + 3 + 4 (in case five tickets are selected) - I find it easier to go about it with isn't shown.

---
Tags: civievent, webform-civicrm
---


title: Multi-Page Event Registration?

text:
# Question
Title: Multi-Page Event Registration?
Our event applications use profiles with a lot of fields. Is there any way within the core of Civi to break up our application page into multiple pages so users don't see one huge form page with so many fields? Like could we break things up by sets of fields or even by profile?

Or is this the time to start looking into Webform and it's CiviCRM integration module?

# Answer
Some webform\_civicrm examples to get you started:

How to Create webform\_civicrm Registrations with: single Ticket vs Table options and Create Contact Records for all Participants

Webform Event Fees in Combination

How do I configure the new recurring contribution feature in Webform CiviCRM module?

You can make easily make really nice looking pages like this:
> 0 votes

# Answer
This is definitely the time to start looking into Webform and it's CiviCRM integration module! It provides page breaks and much more which is not possible with CiviCRM.
> 0 votes

---
Tags: civievent, registration
---


# Question
Title: CiviCRM Dedupe - How does it really work?
There seems to be some confusion at my current organization re: de-duping. I'm under the impression that if I have two records (organizations)

Case 1: name: St. John's University Zip: 11439

Name: St. John's University Zip: 10301

In order to de-dupe, I would place a "weight" on particular fields. **HOWEVER**

What if I only have the name ? How does one dedupe "St. John's" "St Johns" "St. John's U." Is that technically called deduping ? (pardon if this is a noob question. My first on Stack Exchange)

# Answer
For your specific example, "St. John's" "St Johns" "St. John's U.", you can set up a rule that would find a couple of these but sadly not all of them.

As Erikh implies you could setup a rule that only has one field, in this case organization name. Then if you limit to length of 6 or 7, it would find both the first and last examples plus a couple other possibilities.

The one with the missing period is tough since limited it to 2 would find anything that starts with "St". Of course, if you have one other piece of info like address, city or zip code than the list of possible duplicates could be reduced to something manageable.

A nice enhancement to CiviCRM might be to have an option for dedupe to ignore punctuation.

Finally for completeness here is a link to the online documentation on deduping.

https://docs.civicrm.org/user/en/latest/common-workflows/deduping-and-merging
> 1 votes

# Answer
Whether it is technically called deduping or not, these kind of things do occur in real life :-). You should be able to set up dedupe rules that catches them, and one organization I worked with used different 'levels' of deduping rules in their process. For example:

1. dedupe on something like social security number where it is pretty obvious that they are quite possibly real dedupes, and fix those
2. dedupe on email\_address where there is a reasonable chance that they are dedupes, and fix those
    3. dedupe on something like part of first\_name and part of last\_name, where chances are that in quite a few cases there are no real dedupes, and fix those if fixes are required.

Obviously the system can not tell you if I have a girl called Louise Tomlinson and another girl called Louise Tomlynson that they are the same or actually someone else. It can only flag that they look the same.
> 2 votes

---
Tags: duplicate-contacts
---