# Question
Title: can an event have activities asssociated with it?
Looking to use CIVICRM as an event scheduler with "activities" associated with an event. Similar to class scheduling for a day long seminar.

Event Attendees would sign up for 1 or more activities within the event.

Please advise!

# Answer
> 3 votes
CiviCRM lets you create price sets, which can be used to create an event sign-up with all kinds of different selections, such as workshops in different time slots. You'd create a price set field for each time slot, and the field would be set up with as many options as you needed to choose from. There can be a price associated with each different selection, or they can be "free"/zero dollar, or some combination.

---
Tags: civievent, civimember
---


# Question
Title: Multi-user, non-organization environment?
I'm trying to find a CRM solution that would allow me to 1) hook into an existing "customer"/donor data set, and 2) allow multiple users to keep their own private contact and donation records (i.e. Not a single organization, but a service with a shared database).

Is this something that CiviCRM can be modified to do? Thanks.

# Answer
CiviCRM could certainly do this, but out of the box, the "maintain your own private contact/donation records" wouldn't scale well. You'd either use ACL permissions or you use multi-site, which feels like overkill. I've used both approaches with a handful of segments (12-14 segments, with 1-2 users able to see each segment).

If you wanted to scale well past that, I would write a custom extension to handle your scenario. I would probably use a "contact reference" field to link contacts to a group of contact owners, then use a permission hook to limit access to folks who have that user as their contact reference. You could also use groups instead of contact references, which would let a contact have multiple owners.

As for hooking into an "existing" set, you'd need to import the data. CiviCRM isn't going to be the right tool if the data exclusively lives elsewhere.
> 1 votes

---
Tags: wordpress, user
---


title: CiviDiscount Navigation URL incorrect

text:
# Question
Title: CiviDiscount Navigation URL incorrect
After upgrading to 4.7.0 on Drupal 7.50, the link to the CiviDiscount administration in the CiviCRM navigation menu is incorrect (`cividiscount_reset_1`); see screenshot below.

I have attempted to edit the URL by going to Administer \> Customize Data and Screens \> Navigation Menu. When I open the link to edit it, it reports the wrong information entirely and notice that the info seems to be from the link above it; see screenshots below.

In keeping with the formatting of the other links, which start at `civicrm/`, I edited the link to include the proper URL to the CiviDiscount administration page. I tested this link independently (full URL) in a browser and made sure that it works: `/civicrm/cividiscount?reset=1`. When I save the edit, it shows the same "all reports" that it was before, in the screenshot above. I created a *new* link in the menu, but it goes to `http://civicrm/cividiscount?reset=1` which obviously doesn't work. When I put in the full URL, `https://dev.example.com/civicrm/cividiscount?reset=1`, the URL that it goes to is actually `cividiscount_reset_1`, the original incorrect link from the beginning.

Considerations:

* all other links in the menu look normal, without the underscores and work
* the correct URL for CiviDiscount works when entered manually
* CiviDiscount appears to be functioning normal
* I am running CiviDiscount version 2.6

# Answer
> 2 votes
The problem was resolved once I upgraded the extension to 3.3 and corrected the permissions for the extensions folder for the group. `chmod -R 775 sites/default/files/civicrm/ext`. After the CiviCRM upgrade, the extensions directory changed so permissions needed to be reset also.

---
Tags: drupal, upgrade, extension, cividiscount
---


# Question
Title: configuration variables: where is the documentation?
This is changing between 4.6 and 4.7.

Where is the best place to see what each setting does?

# Answer
Most properties of `CRM_Core_Config` are now handled through the settings layer. For documentation about settings, use the `Setting.getfields` API, e.g.

```
cv api setting.getfields

```

Under the hood, this metadata is stored in `settings/*.setting.php`.
> 1 votes

# Answer
In CiviCRM 4.6, but not in later versions, the source documents the following configuration variables:

`$debug = 0;
$backtrace = 0;
$smartyDir = NULL;
$pluginsDir = NULL;
$templateDir = NULL;
$resourceBase = NULL;
$uploadDir = NULL;
$imageUploadDir = NULL;
$customFileUploadDir = NULL;
$imageUploadURL = NULL;
$extensionsDir;
$extensionsURL = NULL;
$cleanURL = FALSE;
$countryLimit = array('1228');
$defaultContactStateProvince;
$provinceLimit = array('1228');
$defaultContactCountry = '1228';
$defaultCurrency = 'USD';
$lcMessages = 'en_US';
$dateformatDatetime = '%B %E%f, %Y %l:%M %P';
$dateformatFull = '%B %E%f, %Y';
$dateformatPartial = '%B %Y';
$dateformatYear = '%Y';
$dateformatTime = '%l:%M %P';
$timeInputFormat = 1;
$dateInputFormat = 'mm/dd/yy';
$fiscalYearStart = array(
$moneyformat = '%c %a';
$moneyvalueformat = '%!i';
$currencySymbols = '';
$defaultCurrencySymbol = '$';
$monetaryDecimalPoint = '.';
$monetaryThousandSeparator = ',';
$gettextCodeset = 'utf-8';
$gettextDomain = 'civicrm';
$gettextResourceDir = './l10n/';
$userFramework = 'Drupal';
$userFrameworkVersion = 'Unknown';
$userFrameworkUsersTableName = 'users';
$userFrameworkClass = 'CRM_Utils_System_Drupal';
$userHookClass = 'CRM_Utils_Hook_Drupal';
$userPermissionClass = 'CRM_Core_Permission_Drupal';
$userPermissionTemp = NULL;
$userFrameworkURLVar = 'q';
$userFrameworkDSN = NULL;
$userFrameworkBaseURL = NULL;
$userFrameworkResourceURL = NULL;
$userFrameworkFrontend = FALSE;
$userFrameworkLogging = FALSE;
$maxImportFileSize = 1048576;
$maxFileSize = 2;
$localeCustomStrings = NULL;
$mapProvider = NULL;
$mapAPIKey = NULL;
$geoProvider = NULL;
$geoAPIKey = NULL;
$geocodeMethod = '';
$mapGeoCoding = 1;
$logging = FALSE;
$empoweredBy = TRUE;
$enableComponents = array(
$enableComponentIDs = array(1, 6, 2, 3, 4, 8);
$enableSSL = FALSE;
$fatalErrorTemplate = 'CRM/common/fatal.tpl';
$fatalErrorHandler = NULL;
$legacyEncoding = 'Windows-1252';
$fieldSeparator = ',';
$maxLocationBlocks = 2;
$captchaFontPath = '/usr/X11R6/lib/X11/fonts/';
$captchaFont = 'HelveticaBold.ttf';
$includeWildCardInName = 1;
$includeEmailInName = 1;
$includeNickNameInName = 0;
$smartGroupCacheTimeout = 5;
$defaultSearchProfileID = NULL;
$dashboardCacheTimeout = 1440;
$doNotResetCache = 0;
$includeAlphabeticalPager = 1;
$includeOrderByClause = 1;
$oldInputStyle = 1;
$formKeyDisable = FALSE;
$inCiviCRM = FALSE;
$componentRegistry = NULL;
$doNotAttachPDFReceipt = FALSE;
$wkhtmltopdfPath = FALSE;
$secondDegRelPermissions = FALSE;
$wpBasePage = NULL;`

The 4.7 equivalent source is here
> 1 votes

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


# Question
Title: Documentation on the _civicrm_api3_* _spec functions
I have a working extension with a working API hook `civicrm_api3_contact_getclif($params)`, but I can't find the documentation for the `_spec` function beyond the suggestion to have one

I wrote this function and it appears to work (ie the params are appearing in the API explorer as required), but I suspect there is more to this function.

What else can I include in this function to provide more metadata about the API I am writing?

`function _civicrm_api3_contact_getclif_spec(&$spec) {
 $spec['clif']['api.required'] = 1;
$spec['length']['api.required'] = 1;
}`

Can anyone point me to the source file that calls the `*_spec()` function if there is no doco?

# Answer
> 2 votes
Have a look at api/v3/Generic.php's civicrm\_api3\_generic\_getfields method

---
Tags: api, extension, hooks
---


title: How to delete Field Mapping

text:
# Question
Title: How to delete Field Mapping
How do you delete field mapping you saved? Have done a lot of work and learning system and now built up a bunch I won't use again but can't find anywhere in guide/online how to get rid of them.

# Answer
> 4 votes
Go to :

> Administer -\> System Settings -\> Import/Export Mappings

There you can find all existing mappings and you can delete unwanted mappings there.

Check below link for more details :

https://www.techpond.in/solved-how-delete-field-mapping-civicrm

---
Tags: import
---


# Question
Title: How to let extension users choose cache system?
CiviCRM contains some useful caching infrastructure (confluence wiki and related question).

If I am creating a module and I would like to allow users to override the default `Civi::cache()` **specifically for this extension** how should I do that?

I think putting some settings (maybe a factory function?) in the `civicrm.settings.php` would be the best way? Is this correct? And any examples?

I'm thinking I could just put something like this in my code:

`if (function_exists('myextension_cach_factory')) {
 $cache = myextension_cach_factory();
}
else {
 $cache = Civi::cache();
}`

Then the settings file could contain something like

`// civicrm.settings.php
function myextension_cache_factory() {
 return new CRM_Utils_Cache_SerializeCache(array());
}`

or maybe even:

`//civicrm.settings.php
function myextension_cache_factory() {
 return new CRM_Utils_Cache_Memcached(array(
 'host' => 'localhost',
 'port' => 11211,
 'timeout' => 3600,
 'prefix' => 'mec_',
 ));
}`

## Background:

`$civicrm_root/CRM/Utils/Cache/Interface.php` defines a minimal standard interface for caching with get(), set(), delete() and flush() methods.

`$civicrm_root/CRM/Utils/Cache/` has these useful looking implementations:

`APCcache.php
ArrayCache.php
Memcache.php
Memcached.php
NoCache.php
SerializeCache.php
SqlGroup.php`

# Answer
> 4 votes
### 1. CRM\_Utils\_Cache::create()

When looking through the list of cache drivers, you see options like `Memcache`, `Memcached`, and `Redis`. Generally there's little reason why a deployment would use all three -- rather, the typical question this:

* Do we have *any* kind of high-speed/shared/memory-based cache? If so, use it.
* Do we have any kind of SQL-backed cache? If so, use it.
* Otherwise, use an ephemeral `array()` (for the duration each request)

In v4.7, `CRM_Utils_Cache::create()` is a factory function which accepts an ordered list of drivers, and it picks the first one that's usable, e.g.

```
$myCache = CRM_Utils_Cache::create(array(
  'name' => 'somethingsomething',
  'type' => array('*memory*', 'SqlGroup', 'ArrayCache'),
));

```

This aims to address the typical use-case by making it unnecessary for the admin to configure anything extra for your specific extension.

Your extension would need to retain a copy of that cache object, e.g.

```
function myextension_cache() {
  if (!isset(Civi::$statics['myextension_cache'])) {
    Civi::$statics['myextension_cache'] = CRM_Utils_Cache::create(array(
      'name' => 'somethingsomething',
      'type' => array('*memory*', 'SqlGroup', 'ArrayCache'),
    ));
  }
  return Civi::$statics['myextension_cache'];
}

```

I believe this answers the typical requirement/issue when someone wants to configure the extension's cache, but it doesn't literally answer the question...

### 2. Named services and caching

The Symfony service container is a general-purpose tool for naming and tracking a bunch of objects -- cache services, database services, entity-repositories, etc. Rather than have a hundred functions like `myextension_cache()` which hard-code the factory, we put all the factories together in the container. This pattern improves our leverage; in principle, you can expose the container to different processes, e.g.

* Reading multiple YAML/XML files to configure the container
* Allowing extensions/hooks to alter the container
* Allowing site admins to alter the container
* Allowing dev-tools and admin-tools to inspect the container

For this reason, new caches in core tend to be created through the container, e.g.

However, at this point, the container in Civi needs improvement. For example, you can alter the container via `hook_civicrm_container`, but there's no YAML/XML/annotation mechanism for updating the container, and there's no mechanism for site-admins to modify services via config file (`civicrm.settings.php`).

The long-term goal is to shift more service-management into a container so that questions like "How does a site admin customize service X?" have a categorical answer. Improving the container is very much patch-welcome.

---
Tags: extension, php, cache
---


# Question
Title: CiviCRM Dashboard not working (as reported by Karl Rudnick)
I am waiting for the answer to Karl Rudnick's question. In my case I was on a clean new install of 4.7.12 and ran an automated upgrade of the "volunteer" extension. The dashboard then shows the same as Rudnick's only with 4.7.12 as the version instead of 4.7.14. After that I upgraded CiviCRM to version 4.7.14 hoping to solve the problem. No luck. I then disabled all CiviCRM extensions (volunteer, booking, and dependencies) since I was not using them. That had no effect either. Clicking on the "Configure Your Dashboard" has no effect. All other functionality within CiviCRM still works and the dashboard was never important to me anyway but the future looks gloomy when something is all screwed up.

*The requested page "/welcome?prot=1&ver=4.7.12&uf=WordPress&sid=c4498a5126be0e5320b4c7260613feb0&lang=en\_US&co=1228" could not be found.*

# Answer
This problem has "gone away". I have to assume that it was related to something in a cache somewhere, either in my browser or on the website. I tried clearing both in the usual ways before, when there was a problem. Now, two days after the last time I accessed the site it seems to be working correctly.
> 1 votes

---
Tags: wordpress, dashboard
---


# Question
Title: Unable to create Joomla user account through CiviCRM profile
Running Joomla 3.5.1, CiviCRM 4.7.7 with the user registration profile set to require Joomla account creation, a new civiCRM user profile is created, but a Joomla user account isn't created. The user registration profile worked in the past, but I don't know exactly when it stopped working. Creating a Joomla user account with using the default Joomla registration form directly works. Any suggestions for resolving?

# Answer
> 2 votes
This issue is coming in case of multilingual site.

To resolve this issue , go to Root/components/com\_users/models/registration.php,near line no. 307 find below mentioned code

```
    if (JLanguageMultilang::isEnabled())
    {
        $form->setFieldAttribute('language', 'type', 'frontend_language', 'params');
    }

    if (empty($form))
    {
        return false;
    }

```

**Replace with** `if (empty($form))
{
 return false;
}`

`if (JLanguageMultilang::isEnabled())
{
 $form->setFieldAttribute('language', 'type', 'frontend_language', 'params');
}`

Try this solution.

---
Tags: profile, joomla, registration, user-account
---


# Question
Title: civix civicrm:ping not printing any output
I am running CiviCRM on Mac OSX 10.11.3, using the latest Bitnami CiviCRM/Drupal stack (bitnami-civicrm-4.6.11-0-osx-x86\_64). I have civix-15.04.1 installed as instructed (under $HOME/civix), and have it added to the path. Likewise I have updated the PATH to use the version of PHP provided by the stack.

While I can use civix successfully to run commands like:

`$ civix generate:module`

when I try and run the following command (as a pre-req to generating custom-xml):

`$ civix civicrm:ping`

I get no output whatsoever (ie silent failure).

I am running the command from within the web root.

Anyone experienced this before? Any pointers greatly appreciated.

# Answer
I would try

```
civix civicrm:ping -v

```

or even:

```
civix civicrm:ping -vvv

```

as the first thing as that could show something useful in the future.

civix will fail silently if your civicrm.settings.php file:

* is turning down phps error reporting and it hits an error
* contains a `die` or `exit` command

Eventually I figured out the problem as here:

`// civicrm.settings.php
// set up php to show errors:
if (isset($_SERVER['HTTP_HOST']) && strstr($_SERVER['HTTP_HOST'], 'dev')) {
 error_reporting(E_ALL | E_STRICT);
 ini_set('display_errors', TRUE);
 ini_set('display_startup_errors', TRUE);
}
else {
 error_reporting(0); // <<< this is bad if you cant find your problem!!
}`

Inserting this in the else section confirmed that `$_SERVER['HTTP_HOST']` was undefined:

`echo '$_SERVER: '.json_encode($_SERVER,JSON_PRETTY_PRINT)."\n";`

So I was able to correct this just by setting up a mock value in bash to fix my civicrm.settings.php logic, and also to allow Drupal to find the right `sites/XXX/settings.php` file:

```
declare -x HTTP_HOST=contact-qld-dev1.myorg.example.com

```
> 1 votes

# Answer
As Drupal bootstraps, if it cannot find a database configuration it will attempt to do a URL redirect to the install page. Obviously this isn't helpful in a script where drupal will just quietly terminate.

Because CiviCRM and Drupal use different logic to identify your `civicrm.settings.php` and `settings.php` it is possible that the bootstrapping maybe attempting to look in different places.

You can verify that both these files are loading during the bootstrap by inserting the magic line at the top and tail of each file:

```
    echo 'got here! #'.__LINE__.' '. __FILE__."\n";

```
> 1 votes

# Answer
The other issue to be aware of is that `cv`, `civix` and other scripts bootstrap your CMS (eg Drupal) **after** it boots CiviCRM.

So this means that your `civicrm.settings.php` file should not depend on settings set in you `settings.php` file.
> 0 votes

---
Tags: extension, developer, php, civicrm.settings.php, civix
---


# Question
Title: Is there a recipe for converting fields to select2?
Examples ...

* Create event - add location - it's hard to find locations with the existing dropdown
* Search builder - Contact Tag(s) IN - dropdown gets hard to use with many tags

I'd be happy to supply patches for these but I'm not happy I understand the scope of such a change.

Is there a PR that shows how this should be done? A good example of a field being changed to select2?

# Answer
> 3 votes
In general, a field can be made into select2 simply by adding the css class "crm-select2" to it.

Here is a PR to add it to the existing location field you mentioned. Please try it out and leave a comment on the PR to say you've tested it and how it works for you - that will speed along the review process and we'll be able to get that merged into the next release of CiviCRM.

Search builder is kinda it's own thing. Changing it to use select2 is certainly possible but would take some doing, you'd need to alter the javascript code somewhat.

---
Tags: core
---


# Question
Title: best practice for using core base functions (CRM_Utils_System_Base) from an extension?
`CRM_Utils_System_Base` defines a great set of key functions that look like they should work in any system.

What is the correct way to access this functionality within an extension?

FYI these are the classes public methods:

`addHTMLHead($head)
addScript($code, $region)
addScriptUrl($url, $region)
addStyle($code, $region)
addStyleUrl($url, $region)
appendBreadCrumb($breadCrumbs)
appendCoreResources(&$list)
authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL)
checkPermissionAddUser()
clearResourceCache()
cmsRootPath()
createUser(&$params, $mail)
flush()
getBestUFID($user = NULL)
getBestUFUniqueIdentifier($user = NULL)
getDefaultBlockLocation()
getDefaultSiteSettings($dir)
getLoggedInUfID()
getLoggedInUniqueIdentifier()
getLoginDestination(&$form)
getModules()
getTimeZoneOffset()
getTimeZoneString()
getUFLocale()
getUfId($username)
getUniqueIdentifierFromUserObject($user)
getUser($contactID)
getUserIDFromUserObject($user)
getUserRecordUrl($contactID)
getVersion()
isUserLoggedIn()
languageNegotiationURL(
loadUser($user)
logger($message)`logout()`mapConfigToSSL()
outputError($content)
permissionDenied()
postURL($action)
resetBreadCrumb()
setMessage($message)
setMySQLTimeZone()
setTitle($title, $pageTitle = NULL)
setUserSession($data)
theme(&$content, $print = FALSE, $maintenance = FALSE)
updateCMSName($ufID, $email)
updateCategories()
url($path = NULL, $query = NULL, $absolute = FALSE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE)
userLoginFinalize($params = array())`

(note a few of these are marked as only be called in certain contexts)

# Answer
> 3 votes
This base class is not intended to be used by itself, but extended based on the CMS. CiviCRM will automatically give you an instance of the correct object which extends this base class. You can access it via the `CRM_Utils_System` static methods. For example:

```
CRM_Utils_System::appendBreadCrumb($something);

```

or

```
CRM_Utils_System::isUserLoggedIn();

```

# Answer
> 2 votes
It's probably easier to answer based on a specific need rather than your more generic "hey, found a stash of toys, can I play with them? ;)"

They are a few that you shouldn't use directly but use the more specific functions, so instead of:

```
addHTMLHead($head)
addScript($code, $region)
addScriptUrl($url, $region)
addStyle($code, $region)
addStyleUrl($url, $region)

```

it's more common/recommended to use CRM\_Core\_Resources

```
CRM_Core_Resources::singleton()
->addScriptFile(...)
->addStyleFile(...)
...

```

# Answer
> 0 votes
There is this example: `CRM/Utils/System.php-1503- /**
CRM/Utils/System.php-1504- * Check if user is logged in.
CRM/Utils/System.php-1505- *
CRM/Utils/System.php-1506- * @return bool
CRM/Utils/System.php-1507- */
CRM/Utils/System.php:1508: public static function isUserLoggedIn() {
CRM/Utils/System.php-1509- $config = CRM_Core_Config::singleton();
CRM/Utils/System.php:1510: return $config->userSystem->isUserLoggedIn();
CRM/Utils/System.php-1511- }`

---
Tags: extension, php, coding-standards
---


title: private or protected class properties

text:
# Question
Title: private or protected class properties
I'm looking at a class in CRM\_Utils\_Cache here specificly and it looks exactly like what I need to write some unit tests against my extension.

The issue is that the `$cache` array is `private` rather than `protected`...

This means I can't extend this class into a test mock that allows my unit tests to manipulate and observe the cache state.

For this reason I'm wonder if there is a downside to changing this (and maybe other) properties to `protected`?

# Answer
> 3 votes
I think submitting a PR to make this variable protected would be perfectly reasonable.

Alternatively, there is a way to access private properties in PHP for the sake of unit testing via Reflection. It's slightly cludgy but it does work.

---
Tags: unit-testing, coding-standards
---


# Question
Title: CiviCRM Dashboard not working on local Win 10 install; live server okay
I recently made a mirror on my laptop running XAMPP. Wordpress 4.6.1 + CiviCRM 4.7.14. Everything works fine on the front-facing site and everything seems to work fine in the back-end, except the dashboard that comes up. There is a message in the default image in the screenshot below that says "The requested page "/welcome?prot=1&ver=4.7.14&uf=WordPress&sid=66b480f3fa29fea3920454ef21065ed5&lang=en\_US&co=1228" could not be found." Note that I also upgraded the Wordpress to 4.7 which is one of the reasons I created the local version - to uncover some upgrade issues that I resolved. The CiviCRM dashboard issue was there prior to the upgrade as well. I can easily restart with backups of our LIVE site where everything, including CiviCRM dashboard, is in good shape.

Anyone have an idea how to fix this? Thanks in advance...

# Answer
> 1 votes
Well, this is embarassing as the answer was simply to clear all browser cache AND **cookies**. I had only cleared the browser cache before and just last night cleared the cookies for something else. When I brought up my local win Wordpress+CiviCRM under xampp, the CiviCRM dashboard was back in business! I apologize to those who took the time to help diagnose, but thank you for doing so. I'll add a cookies tag to this post ;)

# Answer
> 2 votes
Did you change the various URLs/paths in civicrm.settings.php and wp-config.php to match the new location?

See this section from How should I copy a site from production to staging? :

> * Replace all the usernames, passwords, paths, etc. in settings.php, civicrm.settings.php, and/or wp-config.php with the values appropriate to the staging server. If using git, these files are ignored in git, only local copies exist.
> * There are a number of values we override in civicrm.settings.php on the staging server to use the appropriate paths...

# Answer
> 2 votes
I'm going to provide one answer for the moment. This appears to be a Windows-only issue. I lifted my wordpress file hierarchy to my linux laptop and set permissions accordingly (chmod 775 all directories, chmod 664 all files, chmod 660 wp-config.php and civicrm.settings.php). Running linux xampp, the CiviCRM Dashboard appears exactly as it does on the live server.

Since it's Windows-only and our server and my second laptop run linux and all is OK, I'm willing to let this go. Also, I tested with Windows Defender and Firewall completely OFF, so that's not the issue. Linux is finicky \[perhaps I should say "precise" which I actually prefer\] with permissions, and there still could be a permission issue on win 10 as I simply inflated the tar.gz backup from our host to my win laptop. I find it easy to set permissions on unix in a directory hierarchy - see fix-wordpress-permissions.sh. I'm not so good with scripts like that on windows, being a long-time (30+yrs) unix person.

I hope this post at least may be useful to someone else. Moral is, at least for me, stick to linux!

---
Tags: wordpress, dashboard, cookies, windows
---


# Question
Title: Cron error after upgrading to 4.7.14 - Function "is_admin()" is missing, even though WordPress is the user framework
I upgraded to 4.7.14 and now I get the following error when running /wp-content/plugins/civicrm/civicrm/bin/cron.php. I'm running Wordpress 4.7.

> Fatal error: Uncaught exception 'Exception' with message 'Function "is\_admin()" is missing, even though WordPress is the user framework.' in /home/mysite/www/www/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/Base.php:261 Stack trace: etc

This is similar to the post Cron error after upgrade to 4.7.1.

cron has been running fine for years previously - on the same host

I'm trying to run:

```
GET 'http://mysite.com.au/wp-content/plugins/civicrm/civicrm/bin/cron.php?name=admin&pass=somepassword&key=sitekey'

```

I can run the jobs manually from the scheduled jobs screen and they complete

I've tried:

1. cli and URL versions
2. changing permissions for cron.php and cli.php
3. confirmed no special characters in password or site key

That's about the extent of my capabilities sadly.. Any suggestions please?

# Answer
> 3 votes
The error message comes from here and indicates that `cron.php` is not bootstrapping the WordPress CMS, so WordPress functions aren't available.

WordPress `is_admin()` is defined in `wp-includes/load.php`. If WordPress was initialised, that function would be present.

If you are able to *configure your cron to execute via commandline* (eg wp-cli method or PHP CLI method) instead of by request to cron.php, that might give you a workaround for whatever issue is affecting this setup. (Edit: Oh, you tried that? Sorry!)

There was a previous report (from 2012) of the same behaviour: CRM-9727: cron.php will not run in Wordpress, is\_admin() call to undefined function.

# Answer
> 1 votes
well its fixed ..sort of

I was advised to use WP-CLI and that got Cron running.. but still dont know why the URL method was failing

dodgy Wordpress plug in? who knows...

---
Tags: wordpress, cron
---


# Question
Title: How do I set the print order for address labels?
I've created a site using Drupal (7.37) and CiviCRM (4.6.2) for a club that I am a member of. We send out a quarterly printed newsletter and sometimes need to insert personalised letters or other items for specific members. I can print the labels but I cannot see a way to control the order in which they come out, meaning that it is a nightmare to match up labels and inserts.

My label sheets come out in the order they were added to the database (ID field) and I'd like them in last name or even membership number (a custom field) order. Additionally the page of printed labels fills the left column, then middle column, then right column when I'd like them alphabetically filling the top row, second row, then third etc.

Is any of this possible?

# Answer
It is complicated to add a sort order on address labels. I think it is possible to add a sort order to your search and that sort order is used in printing labels.

However, in a recent project, we dealt with the exact problem and using the search did not do the trick. I don't know why anymmore. But we solved the problem by creating a custom report template which they are using for their address labels.

You can find an example of such a report at https://github.com/SPnl/nl.sp.bezorggebieden/blob/master/CRM/Bezorggebieden/Form/Report/Tribune/AddressLabel.php#L251 I have added a line marker that is where the processing of the report to PDF starts. This address label report has additional features such as starting on a new page as soon as a switch of a local chapter starts. (This organisation sends sheets with address labels to local chapters).
> 3 votes

# Answer
you can generate a profile (https://docs.civicrm.org/user/en/4.6/organising-your-data/profiles/) and every field you add to the profile is later sortable. check "search-form" under the option "use for". after creating the profile you go to advance search and under "Search views" you can chose the profile you created.

Important: only select fields from type Contact. If not, the profile wont be listed under advance search.
> 1 votes

---
Tags: search-results, addresses, default-settings, address-labels
---


title: PHP Warnings in maildir.php

text:
# Question
Title: PHP Warnings in maildir.php
Running Civicrm v4.7.14 on Wordpress v4.7 PHP v 5.6.29

For the last couple of weeks, I've been getting the following PHP warning emails, mostly hourly, from my host's server, after the CRON runs with cli.php. All permissions are set correctly in root /httpdocs /wp-content /plugins /civicrm /civicrm /bin/cli.php.

My host has investigated the email setup but found no problems.

Everything else with CRON is working normally and all scheduled jobs are being executed as far as I can tell, with the exception of mail\_report where error message is *"Finished execution of Mail Reports with result: Failure, Error message: A fatal error was triggered: is not of type String"*. I'm not sure whether this has any relevance and it would appear that this message was being received prior to when the PHP warnings started.

Mail() is used (rather than SMTP).

The PHP warning messages are as follows: PHP Warning: scandir(INBOX/cur): failed to open dir: No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: scandir(): (errno 2): No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: scandir(INBOX/new): failed to open dir: No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: scandir(): (errno 2): No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: scandir(INBOX/cur): failed to open dir: No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: scandir(): (errno 2): No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: scandir(INBOX/new): failed to open dir: No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: scandir(): (errno 2): No such file or directory in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/mysite.org/httpdocs/wp-content/plugins/civicrm/civicrm/CRM/Mailing/MailStore/Maildir.php on line 85

Lines 85 to 89 in the Maildir.php file shows: foreach (scandir($dir) as $file) { if ($file == '.' or $file == '..') { continue; } $path = $dir . DIRECTORY\_SEPARATOR . $file;

I'm not sure whether I have any missing core files and any help to find out the cause of these warning messages would be greatly appreciated.

# Answer
What this is suggestive of is that the configuration setting for the mail account look in correct as its trying to retrieve emails to see if it needs to process them (for bounces or replies etc) and it can't find the relevant directories

Seamus
> 1 votes

---
Tags: wordpress, php, cron
---


title: automatic word wrapping in Labels?

text:
# Question
Title: automatic word wrapping in Labels?
is there a possibility to activate automatic word wrapping in Labels? If a Name to long actually it dont break the line.

Civi 4.6 Drupal

# Answer
> 1 votes
I would do this with CSS. For a text element to wrap, it needs to have a width set. Something like:

```
.crm-event-label {
        width: 500px;
}

```

(To include Custom CSS, point to a .css file via Administer \> System Settings \> Resource URLs)

---
Tags: address-labels
---


# Question
Title: How do I run PHP Unit Tests w/ XDEBUG from within PHPStorm [on Mac]?
**My tools:**

* Instance generated with buildkit - civibuild: $ civibuild create dmaster --url http://d47.localhost --admin-pass mypass
* Mac OS + PHPStorm 8.0.4 + MAMP (/Applications/MAMP/bin/php/php5.6.10/bin/php)

I've been close to getting this to work a number of times - but still coming up short. I've looked at Eileen's: https://wiki.civicrm.org/confluence/display/CRMDOC/Tests+in+phpstorm and at Tim's How can I use Xdebug with CiviCRM unit tests? \- but something is always slightly different.

UPDATE - after buildkit and phpstorm updates -\> I’ve posted new slides in the answer below!

# Answer
Here are the steps/complete set of screenshots of a configuration that now works for me:

**1) from command line ensure you can run buildkit -\> civibuild**

$ civibuild create dmaster --type drupal-demo --civi-ver master --url http://dmaster.localhost --admin-user myuser --admin-pass mypass

**2) from command line ensure you can run tests** \- that all is working properly

karins-macbook-pro:civicrm sysadmin$ pwd /Applications/MAMP/htdocs/buildkit/build/dmaster/sites/all/modules/civicrm

```
$ cd /path/to/civicrm
$ env CIVICRM_UF=UnitTests phpunit4 ./tests/phpunit/CRM/AllTests.php

Installing dmastertes_7by9i schema

Installing dmastertes_7by9i database
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.

...............................................

.......
^X^C

```

**3) Ensure you can fire up a http://d47.localhost/ in a browser and debug/set breakpoints** anywhere in PHPStorm / step through code in your Drupal/CiviCRM code base - e.g.

**4. PHPStorm: Preferences -\> Languages & Frameworks -\> PHP:**

**5. PHPStorm: Preferences -\> Project: Directories:**

**6. PHPStorm: Preferences -\> Language & Frameworks -\> PHP -\> PHPUnit:**

**7. PHPStorm: Run -\> Edit Configurations -\> Default -\> PHP Unit:**

**8. Run the test by right clicking on the test itself:**

**9. Et voila:**

**UPDATE JULY 2018** After updating buildkit:

```
cd ~/buildkit
git pull
./bin/civi-download-tools

```

I had to make some edits as some of the paths have changed. The edits I made are:

ad 4:

ad 5:

ad 7: note you want to `Include parent environment variables`

And we're up and running again:

**UPDATE AUGUST 2020** After updating buildkit and PHPStorm -\> here's the new screenshots!

Running a test via the command line also using phpunit5 now:

```
karins-MBP:civicrm sysadmin$ env CIVICRM_UF=UnitTests phpunit5 --filter testSubmitWithTax ./tests/phpunit/CRM/Member/Form/MembershipRenewalTest
Parsing schema description /Applications/MAMP/htdocs/buildkit/build/dmaster/web/sites/all/modules/civicrm/xml/schema/Schema.xml
Extracting database information
Extracting table information
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
.                                                                   1 / 1 (100%)
Installing dmastercivi_rb7eb database
Time: 9.92 seconds, Memory: 58.50MB
OK (1 test, 18 assertions)

```
> 9 votes

# Answer
Having a wild guess - are you setting

```
define('CIVICRM_UF', 'Drupal');

```

somewhere in your civicrm.setting file (I know we do)?
> 0 votes

---
Tags: phpunit, xdebug
---


# Question
Title: Can I track single emails with CiviCampaign?
I understand that I can associate mass mailings with campaigns through CiviCampaign. However, it seems that I cannot associate a single contact interaction via email to a campaign. Is that correct?

Scenario: Our NGO regularly has to stay in contact with individuals, e.g. journalists, to promote our individual projects for time periods of usually 6 months. Therefore, we separate these into Campaigns. But as it looks, I cannot associate an individual contact interaction with such an individual campaign/project, right?

Thanks for your help, Bijan

# Answer
You're correct; the email UI (user interface) doesn't allow you to specify a campaign. However, the underlying database table is `civicrm_activity`, which DOES support storing an associated campaign.

You could write an extension (or hire someone to write an extension) that adds this functionality to CiviCRM, and because the underlying table supports what you're doing, it's relatively little work.
> 1 votes

---
Tags: contacts, email, civicampaign
---


# Question
Title: 4.7.14 Wordpress 4.7 problem with contribution form Birth Date
CiviCRM version: 4.7.14
previous version: 4.7.12
Wordpress version: 4.7

My contribution form experience problem at the "Confirm contribution" page.
Upon pressing Confirm Contribution, user is brought back to the "Confirm Contribution" page with error "Please confirm birth date"
The error does not make sense as a birthdate is already in place.
And multiple tries of replacing birthdate with a different value did not help

A forced downgrading to CiviCRM 4.7.12 resolved the issue - a contribution can now go through.

Please advise! :)

# Answer
Hi there there was an issue due to a change made in 4.7.14, It has been fixed in the up coming 4.7.15 version however I would suggest probably the better option is to upgrade and apply the following patch to your code base. https://github.com/civicrm/civicrm-core/pull/9530/
> 1 votes

---
Tags: contribution-page, 4.7.14
---


# Question
Title: How to effectively manage projects and their contacts within CiviCRM?
Good morning,

in our organisation, we frequently have to deal with the following scenario, a practical solution to which with CiviCRM I have so far not been able to establish. I would greatly appreciate insights on how to do this:

Scenario: Our organisation has a large number of diverse contacts from journalists to banks to volunteers. A selection of these regularly needs to be contacted within the scope of a project running for, say, 6 months. The contacts are made individually, not through mass mailings, and contact progress needs to be recorded individually, too. The relevant co-worker needs to be able to pull up a complete list of contacts pertaining to a certain project, quickly grasp the status of each contact and act on new opportunities, challenges, or delays.

Now, I have tried to use CiviCampaign to pull individual selections of contacts out of our overall pool. However, as I cannot track individual contact progress in CiviCampaign (but only mass mailings) this does not seem practical.

I have further tried to separate contact groups by "Groups" or tags and then tried to use a report to get an overview of these. However, as reports are not meant to be interactive, I cannot jump into a contact, work on it and return to the overview in the report easily.

Can somebody advise if this is practically feasible without additional programming?

Thanks! Bijan

# Answer
Have you tried to use CiviCase to simulate a project? You can then add relevant case roles to the case type 'Project' and retrieve all them as relationships with a specific case\_id. This would be a good way to get all contacts relevant to a project? We have used a similar approach with one of our customers succesfully (although we added some stuff too as their requirements were more complicated).
> 2 votes

---
Tags: contacts, groups, civicampaign
---


# Question
Title: What are the core functions an extension can rely on?
It's been said, quite reasonably, that all APIs should have tests, and that if a feature doesn't have tests then coders shouldn't rely on it.

This raises two three questions:

1. other than direct "API3" calls what can I rely on not to change in the future?
2. how can I know which methods have tests?
3. what is the strategy is for introducing new tests to "lock in" certain useful utility methods?

As one small example, specifically I am talking about the "sub-API-API" - eg these type of methods but also accessing other "system" services (like mail, http, debug logging, UF, UI messenging)

(sorry this maybe a bit wooly for SE, but it is something I have struggled with)

# Answer
> 2 votes
Yes, SE isn't designed to have three questions in one, as this leads to a knotted ball of yarn.

1. API calls are intended to have unchanging interfaces for the life of that version of the API, once the version is marked as stable. Currently API v2 has been retired, API v3 has long been stable, and API v4 is in development.

The nuance you note is that we can only ensure that the results returned by the API are stable if there is a test.

I should also note that if a bug is discovered, eg incorrect tax calculations, then fixing the bug may result in changes to incorrect return values from APIs.

2. Look through the directory for tests. Note that it can be appropriate to have multiple tests for a single method, and we would love to improve the robustness of the use cases we have tests for.
3. The most appropriate place to add a test to lock-in current behaviour for an API is likely https://github.com/civicrm/civicrm-core/tree/master/tests, though there are other types of tests in other directories that might be relevant. For a class like CRM\_Utils\_System\_Base, probably add tests under https://github.com/civicrm/civicrm-core/tree/master/tests/phpunit/CRM/Utils. In terms of making utility methods like these have the 'first order' status of a public API method, this is probably something that deserves community discussion. For example, it might be that we could document somewhere a list of methods that are considered public and stable perhaps in a wiki or preferably to my mind in a docblock. Or it might be decided for consistency and improved Developer Experience to wrap the relevant utility functions in an API wrapper. Could you raise this issue in the dev channel at https://chat.civicrm.org or send a message to civicrm-api@lists.civicrm.org after adding yourself at https://lists.civicrm.org/lists ?

---
Tags: api, php, coding-standards
---


# Question
Title: How delete billing address fields on contributing page?
for example https://civicrm.org/contribute joomla + civicrm

we want to keep only values:

```
Select your contribution amount below
Contribution Amount
$ 25.00
$ 50.00
$ 100.00
$ 200.00
$ 500.00

Email Address *

First Name *

Last Name *

Credit Card Information
VisaMasterCardAmexDiscover
Card Number *

Security Code *

Expiration Date *

```

how to leave only the desired values?

# Answer
> 2 votes
As Christia points out, online credit card processing requires an address, so you can't get rid of them.

If your goal is to simplify as much as possible that form, your best strategy would be to not include any profile fields, and then the form would just include the built-in billing fields.

If you do find a payment processor that will work without address fields somehow, then in theory a plugin could be written that would replace those billing fields with different ones. Who knows? It might not be long until you can just put in a mobile phone number instead and it'll look up your information somewhere ...

---
Tags: custom-fields, joomla, fields
---


# Question
Title: How do I access civicrm.setting.php file?
How do I access PHP files? I'm having the problem where when people try to click on a contribution page, this error comes up:

> Sorry but we are not able to provide this at the moment. We can't load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site adminstrator for assistance.
> Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http:// example. org, but some users are accessing the page via http://www. example. org or a domain alias like http://myotherexample. org.
> Error type: Could not find a valid session key.

I've found a few examples of the same thing happening and people keep suggesting that I make sure my base URL is the same as in the civicrm.setting. php file. I found the base URL (it looks fine, and we haven't changed the domain name or anything) but how do I access the file to compare it to? We're on Wordpress v 4.6.1.

# Answer
> 1 votes
If everything is installed in standard, that file should be located here: `<wordpress>/wp-content/plugins/civicrm/civicrm.settings.php`

---
Tags: wordpress, error, contribution-page
---


# Question
Title: How do I make a new Custom Field Set visible in the Tab Display Style?
I have created a new Custom Field Set. When I set Display Style = Inline, the tab shows as expected.

However, when I set Display Style = Tab, it disappears. There is no Custom Fields tab either?

How can I make the new Custom Field Set visible?

Damihyph

# Answer
`Tab` or `Tab with Table` display style creates a separate navigation tab to display and edit the values.

It will be shown as an extra tab in the Contact Summary Page unlike `Inline` which include the set of fields in the main contact `Add/Edit` form and Contact Summary screens.

Note: `Tab with Table` is recommended for customs data sets which allow multiple records.
> 2 votes

---
Tags: contacts, custom-fields
---


# Question
Title: Problem exporting due to multiple addresses of one location type (e.g. two 'home' addresses)
I have run into a problem where someone created a Webform using Webform\_CiviCRM and for some reason added two address field sets to the contact, with the street address in one of them and the city/state/zip in the other. Now the contacts in CiviCRM have two incomplete addresses, both of the type 'Home'. When I try to export them, I'm just getting one of the incomplete addresses.

This old forum thread seems to be related. It looks like the UI on the main contact page prevents creation of multiple addresses of the same type, but the API must still not enforce?

Anyone have a suggestion for how to tackle this and get the addresses merged/squashed into a single address?

# Answer
I would fix this either partially or wholly with SQL. The general approach I'd use is:

* Change the `location_type_id` on one of the two addresses for each contact to an unused location type (creating a new location type if need be).
* Export the contacts with both the "Home" and the unused location type.
* Reimport the data with all address fields designated as "Home" addresses.
* Delete the extra addresses with a SQL statement.

The basic query you want is:

```
SELECT MAX(id), contact_id, COUNT(id) FROM civicrm_address WHERE location_type_id = 1 GROUP BY contact_id HAVING COUNT(contact_id) > 1;

```

`MAX(id)` is the id of the second address created; `MIN(id)` would return the first address id.

Due to this constraint of MySQL, you can't just use this SQL query that would meet the requirements of the first bullet point:

```
UPDATE civicrm_address SET location_type_id=4 WHERE id IN (SELECT MAX(id), contact_id, COUNT(id) FROM civicrm_address WHERE location_type_id = 1 GROUP BY contact_id HAVING COUNT(contact_id) > 1);

```

You can use of the answers on that SE question to work around that (e.g. with a temp table).
> 2 votes

---
Tags: webform-civicrm, export, addresses, duplicate-contacts
---


title: CiviCRM Joomla Demo Site

text:
# Question
Title: CiviCRM Joomla Demo Site
How do we volunteer to help maintain CiviCRM demo sites, such as the one for Joomla? I noticed that an extensions directory hasn't been created and set yet and it would be cool to be able to test out extensions. How are the demo sites maintained and who is in involved? Is there a secret handshake to get involved?

http://joomla.demo.civicrm.org/administrator/

# Answer
You can ask to help out in the "infrastructure" channel on https://chat.civicrm.org!

The demo sites are automatically regenerated nightly via a script based on civicrm-buildkit \- so it's not really sufficient to change the setting. Folks in that channel can help get others up to speed though.
> 1 votes

---
Tags: joomla, extension, demo-site
---


# Question
Title: Renewal Link Results In Too Many Redirects Error
I'm trying to setup membership renewals for an organisation I've just migrated over to CiviCRM, all of the membership details seem to have been imported correctly (dates and details show correctly). All memberships expired on 31.12.16.

I am trying to setup the renewal emails and have emailed a dummy run to myself via my membership record. Having reviewed the guidance at https://docs.civicrm.org/user/en/master/membership/renewals/ I have set the URL in the emails to

> my.org/joomla/index.php?option=com\_civicrm&task=civicrm/contribute/transact&reset=1&id=N&{contact.checksum}&cid={contact.contact\_id}

When the link comes through on the emails it is populated correctly with the checksum and ID but when I click on it I get a too many redirects error.

I've found something strange in that if the link is clicked as is - eg.

> my.org/joomla/index.php?option=com\_civicrm&task=civicrm/contribute/transact&reset=1&id=N&{contact.checksum}&cid={contact.contact\_id}

(obviously populated with info) I get an error. However, if I set the URL to

> my.org/joomla/index.php?option=com\_civicrm&task=civicrm/contribute/transact\**?\**reset=1&id=N&{contact.checksum}&cid={contact.contact\_id}

, I initially get a page not found error, if I then change the ? symbol back to an & symbol the renewal page all completely filled in as it should be appears.

Does anyone know what's going on, I can't ask my members to renew using an incorrect link that requires manual modification.

I have replicated this error both in Chrome and Safari. I am using Joomla version 3.6.5. I am using CiviCRM version 4.7.14.

Please help!

# Answer
"Too many redirects" is almost always caused by URL rewrites. Your web server software (e.g. Apache, nginx) handles URL rewrites, so it's most likely that your problem lies in the configuration of that software, not CiviCRM. To my knowledge, CiviCRM doesn't generate a redirect on any links other than click-through links.

To resolve this, I would take the following two steps:

* Press "F12" to open your Developer Tools (in Chrome or Firefox; Safari's are lacking). Go to the "Network" tab.
* Trigger the "too many redirects" error. You should see a bunch of network requests. Note the URL, and look for any patterns. A common pattern is:

http://my.org/civicrm/

http://my.org/civicrm/civicrm

http://my.org/civicrm/civicrm/civicrm

etc.

* Find the "rewrites" section of your web server configuration. Look for the pattern that matches the URLs you found on your Network tab. Tweak that rewrite rule and restart your web server software.
> 1 votes

---
Tags: civicontribute, civimember, joomla
---


title: How do I delete activities?

text:
# Question
Title: How do I delete activities?
How do I delete an activity that I have created and assigned to myself?
I cannot see a button that says delete, only an edit button?

# Answer
There should be a link on the "Activities" tab marked "Delete" for each activity listed. See screenshot:

If you do NOT see this button, it's most likely that you don't have the "Delete Activities" permission. Please speak to whomever manages permissions for your CiviCRM installation.
> 1 votes

---
Tags: delete
---


title: CiviDiscount Isn't Tracking Usage

text:
# Question
Title: CiviDiscount Isn't Tracking Usage
(Now CiviCRM 4.7.0, Drupal Commons 7.50 and CiviDiscount 3.3)

If a user uses a coupon code, the coupon code is no longer tracking the number of times it is used or who used it. It appeared to be working until I realized that it only tracks two situations: if there was money exchanged (not a 100% discount) and/or if the coupon was used during a transaction put in on the backend and not by the user.

Furthermore, you should be able to assign an organization to the code so that the "codes assigned" and "codes used" is tracked. As it sits, those tabs do not report anything.

Screenshot of how discount code is set up:

Screenshot of membership:

Screenshot of price set used:

Also, when I first look up "Test Organization for Code", the organization that I applied the the test discount to, the tab clearly shows that there is a code assigned, however, when the tab is clicked on, nothing shows and the value is changed to zero. This could be an important clue.

Lastly, here you can see a MySQL table showing all recorded uses of the same code (item\_id=2) but the data is being recorded differently. The last 4 were entered through CiviCRM and the first 2 were entered through a Contribution page, when it was still tracking; there should be about 25 rows, but the rest of the uses were never recorded:

Here you can see where the discount code that was used is still reporting 0 uses:

Here you can see where the test user that used the code is still showing that no code was used:

**Things I've Tried:**

* Changing CiviCRM to a standard install.
* Upgrading Drupal Core, CiviCRM and CiviDiscount to latest major versions.
* Was unable to reproduce the error on my own simplified sandbox using the same versions

(Edited from running CiviCRM 4.3.8 with Drupal 7.37 (Commons))

# Answer
> 2 votes
I was able to isolate the CiviDiscount tracking problem in a separate sandbox site. Using Drupal Commons at the latest version, CiviCRM 4.7.4, and CiviDiscount 3.3, with no customizations or other modules installed, I tested discount codes and they were not tracked, just as described in my question.

When I upgraded to the latest version of CiviCRM (4.7.14) the issue was resolved.

In my first round of testing using a sandbox, I had installed Drupal but not Drupal Commons and CiviCRM 7.4.9 and the discount code worked properly.

# Answer
> 2 votes
I'll ad this as an answer so it's not lost in a comment. Steps to figure this out would be:

1. CiviDiscount is installed on demo/dmaster: try and reproduce your scenario/bug on demo/dmaster - starting by adding discount config here: http://dmaster.demo.civicrm.org/civicrm/cividiscount
2. If you can reproduce the issue you're seeing on: http://dmaster.demo.civicrm.org/civicrm \- then file an issue here: https://github.com/dlobo/org.civicrm.module.cividiscount/issues
3. If things are working properly on http://dmaster.demo.civicrm.org/civicrm \- the issue may have been resolved and you would then look at upgrading your own instance to that CiviCRM version/CiviDiscount version.

All the best!

---
Tags: drupal, cividiscount
---


# Question
Title: Is there a way to easily locate Profile entries?
We use profiles as contact forms on our website, using custom fields for the form options.
I am trying to find a list of the contacts that have recently submitted forms, but there doesn't seem to be a way to do it. I have made the form searchable, but when I use the advanced search to look in the profile fields that I created, it shows me all of the contacts in the database rather than just the ones that have submitted data into those custom fields. I would like to search for either:
\- forms that are not null, or
\- forms by entry date
I just need some way to locate the most recent profile submissions.

# Answer
Profile don't really work like that. They are just a way to view, enter and/or change data. Once submitted, the data is put into the database and the profile zeroed out, so to speak. By default no record is kept of when a specific profile was used.

Now having said that, there can be ways to get at the data. If the data changes something on the contact record than you can look at the last modified date on the contact record (under advanced search, change log). Granted if someone changes something via the standard form you'll get those as well.

You can add a custom field or fields with a default name for the profile so every time that profile gets used that custom field gets populated. Capturing the date is doable but requires hooks or database triggers.

I think if you turn on complete logging (administer =\> System Settings =\> Misc) you can capture all changes to any table. This options creates a lot of tables and triggers in the database so if you use it, try it in test first.

If you are using drupal then you might look at webforms. They act like a bit more like I think you'd like. The data from each form submission is saved as a form, kind of like having a paper form of each. There are some options for analysis, viewing the data as a table or downloading it into excel.
> 4 votes

# Answer
Random thought. If you add the Note(s) field to the profile then you do get 'something' with today's date. And presumably if you hid it and prefilled it with eg the name of the profile (eg via js) then you would have a record of who filled in the profile when, and you can search for Notes by 'subject' etc
> 2 votes

# Answer
I am having the same issue. We are using several profiles in out website. And searching for recent registration was mission impossible. My last thought now is to use all forms as events. Because under the events you have a link to see latest participants. Which equals all the form sumbissions per event.
> 1 votes

---
Tags: profile
---


# Question
Title: Error when adding an option to an existing price set field
Joomla 2.5.28 CiviCRM 4.7.14

I am working with a price set for an event. Most fields are radio or checkbox fields. When I go back to add another option to the field, CiviCRM throws a database error, but still saves the option.

Below is the error log corresponding with the error. Wondering if anyone else has seen this issue and if there is a fix OR if I need to submit an issue to JIRA.

```
Jan 05 17:54:39  [info] $backTrace = #0 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(229): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
#2 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error))
#3 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: syntax error", -2, 16, (Array:2), "SELECT id FROM civicrm_option_signup WHERE price_option_id = ; [nativecode=10...")
#4 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-2, 16, (Array:2), "SELECT id FROM civicrm_option_signup WHERE price_option_id = ; [nativecode=10...")
#5 [internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -2, NULL, NULL, "SELECT id FROM civicrm_option_signup WHERE price_option_id = ; [nativecode=10...", "DB_Error", TRUE)
#6 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8))
#7 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))
#8 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -2, NULL, NULL, "SELECT id FROM civicrm_option_signup WHERE price_option_id = ; [nativecode=10...", "DB_Error", TRUE)
#9 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-2, NULL, NULL, NULL, "1064 ** You have an error in your SQL syntax; check the manual that correspon...")
#10 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#11 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("SELECT id FROM civicrm_option_signup WHERE price_option_id = ;")
#12 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2438): DB_common->query("SELECT id FROM civicrm_option_signup WHERE price_option_id = ;")
#13 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1627): DB_DataObject->_query("SELECT id FROM civicrm_option_signup WHERE price_option_id = ;")
#14 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(354): DB_DataObject->query("SELECT id FROM civicrm_option_signup WHERE price_option_id = ;")
#15 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1297): CRM_Core_DAO->query("SELECT id FROM civicrm_option_signup WHERE price_option_id = ;", TRUE)
#16 /home/ipca/public_html/media/civicrm/ext/com.aghstrategies.eventmembershipsignup/otherSignupAdmin.php(198): CRM_Core_DAO::executeQuery("SELECT id FROM civicrm_option_signup WHERE price_option_id = ;")
#17 /home/ipca/public_html/media/civicrm/ext/com.aghstrategies.eventmembershipsignup/eventmembershipsignup.php(36): eventmembershipsignup_option_admin_postProcess(Object(CRM_Price_Form_Option))
#18 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Utils/Hook.php(228): eventmembershipsignup_civicrm_postProcess("CRM_Price_Form_Option", Object(CRM_Price_Form_Option))
#19 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Utils/Hook.php(151): CRM_Utils_Hook->runHooks((Array:5), "civicrm_postProcess", 2, "CRM_Price_Form_Option", Object(CRM_Price_Form_Option), NULL, NULL, NULL, NULL)
#20 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Utils/Hook/Joomla.php(100): CRM_Utils_Hook->commonInvoke(2, "CRM_Price_Form_Option", Object(CRM_Price_Form_Option), NULL, NULL, NULL, NULL, "civicrm_postProcess", "joomla")
#21 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Utils/Hook.php(403): CRM_Utils_Hook_Joomla->invoke(2, "CRM_Price_Form_Option", Object(CRM_Price_Form_Option), NULL, NULL, NULL, NULL, "civicrm_postProcess")
#22 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php(462): CRM_Utils_Hook::postProcess("CRM_Price_Form_Option", Object(CRM_Price_Form_Option))
#23 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php(436): CRM_Core_Form->postProcessHook()
#24 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess()
#25 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(61): CRM_Core_StateMachine->perform(Object(CRM_Price_Form_Option), "next", "Next")
#26 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Price_Form_Option), "next")
#27 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Price_Form_Option), "next")
#28 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("next")
#29 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Price/Page/Option.php(235): CRM_Core_Controller->run()
#30 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Price/Page/Option.php(323): CRM_Price_Page_Option->edit(1)
#31 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(310): CRM_Price_Page_Option->run((Array:5), NULL)
#32 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#33 /home/ipca/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:5))
#34 /home/ipca/public_html/administrator/components/com_civicrm/admin.civicrm.php(121): CRM_Core_Invoke::invoke((Array:5))
#35 /home/ipca/public_html/administrator/components/com_civicrm/admin.civicrm.php(40): civicrm_invoke()
#36 /home/ipca/public_html/libraries/joomla/application/component/helper.php(380): require_once("/home/ipca/public_html/administrator/components/com_civicrm/admin.civicrm.php")
#37 /home/ipca/public_html/libraries/joomla/application/component/helper.php(348): JComponentHelper::executeComponent("/home/ipca/public_html/administrator/components/com_civicrm/admin.civicrm.php")
#38 /home/ipca/public_html/administrator/includes/application.php(153): JComponentHelper::renderComponent("com_civicrm")
#39 /home/ipca/public_html/administrator/index.php(46): JAdministrator->dispatch()
#40 {main}

```

# Answer
> 1 votes
This doesn't seem to be a core error as the table `civicrm_option_signup` where the DB error is thrown is a non-civi and maybe added through a custom code, extension etc. So you cannot raise an issue for this in JIRA.

From the backtrace, it looks like the error originated from an extension `com.aghstrategies.eventmembershipsignup/otherSignupAdmin.php` at line 198 where the incomplete query is being written. Its recommended to ask your developer/maintainer of your site to track why the `price_option_id` is empty at that point.

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


# Question
Title: CiviContribute Pages have differing wrong titles in <head>
We are having a strange issue where different titles for our CiviContribute pages show up in the `<head> <title>` section, so the title shows up wrong in the tab, bookmark, etc. Sometimes it will be the name of one of our CiviContribute pages, and sometimes another. Today, they all say "Donate" for example, which is what one of our CiviContribute pages should be called. But other users will report that the title is "Subscribe" on all the pages, which is the example name of another of our CiviContribute pages.

We are using a really old version and are currently working on updating it now but I wanted to make sure there wasn't a simple explanation before putting it on hold for the upgrade.

Any ideas?

Drupal 7.50, CiviCRM 4.3.8.

# Answer
> 1 votes
Upgrading to the most recent version of CiviCRM (4.7.15) solved this problem.

# Answer
> 0 votes
This can be caused by caching solutions, for instance if you use Drupal with GlobalRedirect or Boost module？

---
Tags: civicontribute, drupal
---


# Question
Title: Multiple contact entries created for WordPress users if they login with non-primary email addresses
We are running WordPress 4.4.2, CiviCRM 4.6.12, and the CiviCRM WordPress Member Sync and CiviCRM WordPress Profile Sync plugins.

Whenever someone logs in with a WordPress user ID / email that is not their primary CiviCRM contact email, a new CiviCRM contact is created. The WP email may be listed as their "home" / "work" / "billing" / etc. email in CiviCRM but a new contact is still created.

In the newly created CiviCRM contact, the email address is set as "home" and "primary". The next time they login, a new contact is created, again with the email set as "home". We end up with a lot of duplicate contacts!

Is this a plugin issue, or a CiviCRM issue?

It seems similar to the question here: Wordpress duplicates my contacts

# Answer
> 3 votes
The issue outlined in the question and comments doesn't exist in the latest version of CiviCRM. Penny mentions that the issues results because "When a Wordpress User is deleted, the WP User ID is not deleted from that contact's CiviCRM contact record".

I tested that this is no longer the case by creating a WordPress user, running `SELECT * from civicrm_uf_match` to find the corresponding entry in that table, then deleting the WordPress user. When I re-ran the SQL statement, I saw that the `civicrm_uf_match` entry was gone.

# Answer
> 0 votes
Certainly with Drupal, the user account is linked to the civi record via a table called uf\_match. That table contains primary email address, drupal user id and civicrm contact id (and other fields not relevant to this question). It is that table that is checked to see if a record already exists for such a user. So it sounds like this would be an extra feature requirement for civi, and i have no idea how complex, so can't be more helpful at this point.

---
Tags: wordpress, duplicate-contacts
---


# Question
Title: Paypal Recurring Transactions Are Broken in 4.7
When posting a recurring transaction with PayPal (offline and online), we're getting a 'Transaction ID not set' Payment Processor error. The payment is created in Paypal.

Checking Civi log file, on offline transactions, getting:

```
[info] Could not find payment processor for contribution record: #######

```

For the online transaction, the log file has:

```
[info] contributionRecur could not be loaded
[info] Contribution record updated successfully
[info] Receipt sent
[info] Success: Database updated

```

This problem seems to have started with the 4.7 upgrade.

Even recurring transactions coming from Paypal are giving the same '\[info\] Could not find payment processor for contribution record:' error.

Site profile settings

# Answer
> 2 votes
You don't say which version of CiviCRM you're using. There were some fixes related to PayPal in 4.7.13, in particular look at CRM-18483 If you're not up on at least 4.7.13, it would be worth upgrading.

(Edited to correct a typo)

---
Tags: paypal, recurring-contributions
---


# Question
Title: Update smart group counts errors with syntax error (AND instead of WHERE in sql)
This is a bit of a corner case. This is reproduced in http://d46.demo.civicrm.org.

Go to Contacts =\> Manage Groups

Click on Update Smart Group Counts (left side below the Find Groups box)

It will error with a syntax error. It errors on the smart group LYBUNT.

This smart group was created with Search =\> Custom Searches =\> Contributions made in Year X and not Year Y.

# Answer
I know this is old but it seems if there is a Smart Group that has no contacts it will throw up an error, at least, it does in my instance. I just disabled that Smart Group and the Update link doesn't throw a syntax error any more.
> 2 votes

---
Tags: smartgroups
---


# Question
Title: Understanding unique vs multiple membership(s) (using Webform)
I am extensively testing CiviMember because I have several Organizations which have different membership types with different duration types.

Memberships will be managed from the Organizations (not from Individuals)

I intend to create memberships via Webforms (Contact1 = Organization ; Contact2 = Individual ; One membership for Contact2)

When I use the same Webform again for the same `Organization, Individual` pair, in certain cases it creates a new (duplicate) membership, in others, it modifies the existing one.

I'd like to understand why and when each case happens (I may be interrested by each, but need to control when)

Thanks in advance

# Answer
When you create a Membership Type you specify the Membership Organization - therefore you would not need the Organisation on the form if that is how you are approaching this.

If you are using 'Inherited Memberships' then you would need the Org on th form.

Based on your comment you are doing the former so I have converted this to an answer.
> 1 votes

# Answer
The Webform integration determines whether to add or update a membership based on the "Membership Organization" of the membership type. Say you have the following membership types defined:

* **Organization: Soccer Club**

*Membership Types:*

1. Youth soccer
    2. Teen soccer
    3. Adult soccer
* **Organization: Tennis Club**

*Membership Types:*

1. Youth tennis
    2. Teen tennis
    3. Adult tennis

Now say you have signed up a person for a "Youth soccer" membership. If you subsequently sign them up for a "Teen soccer" membership, Webform will detect that you are upgrading membership within the same organization and it will bump their existing membership from youth to teen. If however you sign them up for a "Teen tennis", it will leave their soccer membership alone, and add the tennis additionally.
> 3 votes

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


# Question
Title: Excluding blank or null values from report
I'd like to create a report that includes a record if ANY value for a particular column is present, but excludes if there is no value.

For example, for gender of Male or Female, I'd like to filter if someone entered either value. Entries without a value would be excluded.

I did find this question/answer which suggests using multiple choice selection as a workaround.

This answer is not sufficient, since the columns that I want to choose do not have the option to multi select values.

Any suggestions would be appreciated.

# Answer
> 2 votes
I would use the Search Builder (**Search menu » Search Builder**) to select your field with an operator of "Not Empty" (see screenshot below). It's not clear when you say "Report" if a search is sufficient - if it is, you're done.

If you DO need a report, add these users to a group (possibly a smart group, depending on whether you need this on an ongoing basis). Then generate your report, filtering by members of the group.

---
Tags: search, reports
---


# Question
Title: Adding Custom Field to Contact Membership Tab
CiviCRM 4.7.9

I have a custom field that I created for memberships. I would like to have this field displayed as a column within the membership tab when viewing a contact.

I've been digging into the tpl/php files and trying to pin down how to do this, but I keep getting lost.

Can anyone help give me some direction for this?

Thanks!

# Answer
The template you're looking for is templates/CRM/Member/Page/Tab.tpl. The "browse" action is number 16, and takes up the vast majority of the template, starting around line 33.

You'll want to populate the `$activeMembers` and/or `$inActiveMembers` array with modified data. Those are defined in CRM\_Member\_Page\_Tab around line 211, but most likely you'll want to modify the `$membership` array that they're both based on. The `browse()` method of that function is mostly a "while" loop devoted to building the $membership array, but is sadly devoid of hooks.
> 2 votes

# Answer
You can do this using hook\_civicrm\_searchColumns

More information about the hook in this page: https://wiki.civicrm.org/confluence/display/CRMDOC/hook\_civicrm\_searchColumns

Hope this helps.
> 0 votes

---
Tags: civimember, contacts, custom-fields
---


# Question
Title: How can I change activity duration from minutes to hours?
I have a client that reports activity duration in "Units" using hours. Is there a way to configure Civi to use hours? Or, would that require a custom field?

# Answer
> 2 votes
Try the following modules to collect activity data and convert hours to minutes on the front end.

https://www.drupal.org/project/webform\_civicrm https://www.drupal.org/project/webform\_calculator

# Answer
> 1 votes
When recording a new activity, the duration field indicates "minutes", but this is just a label within the form itself - activity reports will provide you with the duration column, but without indication of whether you are talking about minutes or hours, so this leaves you with two options:

1. (preferred) if you know your way into the code of the record activity form, it would be a simple question of changing the label, **OR**
2. if you feel confident with replacing all instances of the word "minutes" with "hours", you can use Administer \> Customize Data and Screens \> Word Replacement **TIP:** using "exact match" also refers to capitalization, so you will need to enter the word "minutes" in lower case in order for any change to take effect. If you want to switch the replacement back from hours to minutes, you will need to enter a new set of words for replacement (disabling a word replacement won't undo what you've already replaced, but it will prevent future replacements).

Hope this helps, Tamar

---
Tags: activity
---


title: CheckSum Profile Update

text:
# Question
Title: CheckSum Profile Update
www....../civicrm/?page=CiviCRM&q=civicrm/profile/edit&gid=1&reset=1&id={contact.contact\_id}&{contact.checksum}

i have finally set up my Checksum for profile update. However when link is clicked inside email i am getting this message- "This profile is configured for contact type 'Individual'. It cannot be used to edit contacts of other types. If I disable the Fist Name and Last Name fields for that profile it works.

Is there a way around this as i really need to have a First Name Last Name.

# Answer
> 2 votes
I'm not sure which CMS you are using but, per the civicrm wiki page, the URL Checksum for standard Profiles (edit mode) is as below:

To send people to a profile use this path where **N** is the ID of the Profile you want to send them to:

```
Drupal: http://www.myorganization.org/civicrm/profile/edit?reset=1&gid=N&{contact.checksum}&id={contact.contact_id}
Joomla!: http://www.myorganization.org/index.php?option=com_civicrm&task=civicrm/profile/edit&reset=1&gid=N&{contact.checksum}&id={contact.contact_id}
WordPress: http://www.myorganization.org/?page=CiviCRM&q=civicrm/profile/edit&reset=1&gid=N&{contact.checksum}&id={contact.contact_id}

```

Hope this helps and solves your problem.

# Answer
> 2 votes
Are you sure you are sending your test email to an individual contact? if you have several contacts that have the same email address (eg info@my.org) that you associated both to your organisation and yourself, civimail might send it to the organisation instead of the individual.

take the id of the contact and view its record and double check it's an Individual.

---
Tags: checksum
---


title: Acknowledgements

text:
# Question
Title: Acknowledgements
I am used to working in Raiser's Edge and DonorPerfect. I am having trouble figuring out how to process acknowledgments in Civi. Is there a way to set up a series of letter templates so that I can assign a letter to each donation and process a group of donations all at once using a word format?

# Answer
> 2 votes
you have a feature to generate pdf letters. You can set up a template and generate the pdf directly.

If you need more advanced merge features and want to work from your word processor, I'd suggest you to export as a csv and do a mail merge with it.

---
Tags: contributions
---


# Question
Title: Is there any reason to not run the scheduled job Clean-up Temporary Data and Files every hour?
I discovered some problems with Smart Groups that use IN search criteria for custom fields not showing counts. I have the scheduled job Rebuild Smart Group Cache running. However, only after running Administer -\> System Settings -\> Cleanup Caches and Update Paths, then selecting Update Smart Group Counts, was I able to see updated Smart Group counts.

It seems running the scheduled job Clean-up Temporary Data and Files *should* do the same thing as Cleanup Caches, since it "\[r\]emoves temporary data and files, and clears old data from cache tables". Is that the case?

Currently the scheduled job Cleanup Caches and Update Paths is disabled.

So - is there any reason to *not* run the scheduled job Clean-up Temporary Data and Files every hour?

Thanks so much!

# Answer
Check how long it takes to run on your system. if it doesn't take too long, I don't see any reason not to run it hourly.
> 3 votes

---
Tags: smartgroups, settings, scheduled-job, cache
---


title: token for country iso code

text:
# Question
Title: token for country iso code
the token {contact.country} returns the full name of the country, I'd need the iso code (eg "FR" instead of "France").

Am I missing the obvious and is there a {contact.country\_iso} hidden somewhere ? is there an extension that does provide this token already?

# Answer
I'm almost certain that such a token doesn't already exist.
> 1 votes

---
Tags: civimail, email, tokens
---


# Question
Title: Is it possible to have an updateable log for an event?
We have a requirement where we want to have a user updateable 'log' (text area) attached to an event. A custom field is the obvious answer but the screen to update the field (event config) would not be suitable as it exposes critical data. Webforms for events are oriented toward contact signups - not at the event level but at the contact level, so are not suitable. And profiles can't be used for events, can they? The event in question is a nightshelter, where we use a webform to sign in guests. We want the night staff to be able to use Civi to keep a log for the night (i.e. the event), but apart from adding a custom field to the event (as described above) there doesn't seem to be a usable solution for us. Any suggestions?

# Answer
> 1 votes
What about using activities and a contact for the shelter? Each activity would be an entry, you can use activity types, so it might make it easier to get some analysis on the log.

There isn't any direct link between the log and the event, but you can filter by date and get the activities linked to a specific event (night).

you could write an extension to change the layout of the event backoffice and provide a filtered view.

# Answer
> 1 votes
I think you'll need custom code to do this. Consider creating an event page that only exposes the name of the event and the custom field used for the log, using an ACL override on the custom page to allow people to edit the event who wouldn't ordinarily be able to.

---
Tags: civievent, 4.7, 4.6
---


# Question
Title: CiviCRM API with Custom Data mixed with Standard Entities
I'm using CiviCRM 4.6 with the new API editor.

I'm attempting to chain a bunch of queries together, which provide cases for a client within a period, along with the linked contact, along with custom data from the case entity, and the contact entity.

I'm wondering the best way to chain this query together? The new case Entity allows retrieval of cases, by case type. If I chain the Contact entity to it via {"cid":"cid"} I obtain a list of client details... However both return just standard fields.

If I enter return fields and select the custom fields, these do not appear in the final result.

So what is the best way to query certain custom field values, which are specific to the case and client? i.e. A custom field ID#370 in Custom Field Group ID#55 for the client, which is a custom field attached to the case.

# Answer
Pasting Adam's comment as the answer:

OK, from my understanding after researching further, you can't retrieve/set custom fields via the case API - Thanks Brian! So basically I have to run multiple queries to get the data, which isn't efficient for large record sets. Hopefully one day I'll get the chance to add custom fields to standard entities on the API! In short, seperate your queries.. you can easily chain Case and Contact with the new API.. but need to get the IDs, and run a customvalue query with these IDs.
> 2 votes

# Answer
I also noticed that querying the API for custom fields does not return them unless they are specified in the return fields. But the field that is listed in the API explorer in not the actual field name, I could not get the fields to return using their "title names" but they do when using the custom\_xx field name.
> 3 votes

---
Tags: api, custom-fields, chaining
---


# Question
Title: Deleted duplicate contact, when try to make login still says the email address is already registered ((Drupal 7.53, CiviCRM 4.6.24)
Someone who signed up on our website was having trouble logging into her account (made via joining membership). I went to manually reset a login for her, and found out that her email address was already being used for a different contact account we had on file (made from joining a mailing list). To fix this, I deleted the latter contact account, so that only her membership one would exist. I then tried to create a login for this account, but every time I do so it says her email address is already registered still, even though I deleted the previous contact file linked to that email address and can no longer find it. Whenever I search for another contact under her name nothing shows up except for the membership one, which is the one I am trying to edit, so I don't know how to access (and DELETE!) this supposed second account that keeps on interfering with her membership one.

# Answer
> 1 votes
When you check availability, it's actually not looking at CiviCRM - it's looking in Drupal. If you're a coder, you can read the code here. Based on this, it seems like you need to delete the Drupal user, not the CiviCRM contact.

**To fix:**

* Go to **CiviCRM menu » Hide menu** to view the Drupal menu (see screenshot).

* Your Drupal menu may vary based on the installed extension, but you'll likely have a "People" menu:

From here, you can delete the Drupal user. Instructions can be found here.

Note that if you create a new Drupal contact with the same email address as a CiviCRM contact's primary contact, the link between the two will be regenerated! So you should never have to delete the CiviCRM contact in this instance.

# Answer
> 0 votes
It sounds like the "deleted" contact record has gone into trash. You may be able to find it by doing an advanced search in contacts, making sure that you tick the "Search in Trash" box. You can delete it from the trash box.

As an alternative, you could restore the record from the trash box and then merge the two records, thereby ending up with only one.

---
Tags: civimember, contacts, user-account
---


# Question
Title: Importing Memberships and Contributions but can't seem to link the two together
I'm using the latest CiviCRM Wordpress version and have imported thousands of contacts and their memberships. The problem is when I attempt to import the associated contributions they seems to be no way to linked the contributions to their memberships. Jon G has answered a similar question (below) but I'm not sure I can use his advise as I have already imported the memberships. Any an all advise welcome.

Bulk Import of Membership Dues - Jon G's Answer

It sounds like your process of importing memberships via CSV and contributions via CSV works - except that your contributions and memberships aren't linked.

If that's correct, I've resolved this when doing migrations as follows:

> Create a custom field for contributions called "external serial" or similar. Create a custom field for memberships also called "external serial". Add a serial number column to your CSV (if one doesn't already exist) before importing it as contributions/memberships. The only important part is that each row have a unique identifier. After import, you can use the shared identifier to create a new CSV with just two columns - membership\_id and contribution\_id (as CiviCRM assigned them). I typically would do this via SQL. Something like this: SELECT cc.id AS contribution\_id, cm.id AS membership\_id FROM civicrm\_contribution cc JOIN civicrm\_value\_importfieldcc\_1 cvi1 ON cc.id = cvi1.entity\_id JOIN civicrm\_value\_importfieldcm\_2 cvi2 ON cvi1.external\_serial\_1 = cvi2.external\_serial\_2 JOIN civicrm\_membership cm ON cvi2.entity\_id = cm.id Create membership payments using this new CSV to link the memberships/contributions. You can do that with the API CSV Import GUI extension or the command-line tool that ships with CiviCRM.

# Answer
The key to my instructions are that there is some unique identifier in both your memberships and contributions. If you don't have one, then you're correct, there's no way to link the two.

That said - you can use some trickery to create a unique identifier after the fact. For instance, if your import data has a contact ID and a transaction date, and you know that one contact never signs up for two memberships in a day, you can create a unique ID based on the data you've already imported to the memberships.
> 3 votes

---
Tags: civimember, import, contributions
---


title: Tracked Opens No

text:
# Question
Title: Tracked Opens No
Track opens stopped working recently. Clicking on tracked opens gnerates the following error message:

```
Fatal error: Class 'Database' not found in /home/xxxxxx/public_html/includes/bootstrap.inc on line 3462

```

The site is running:

* Drupal 7.53
* CiviCRM 4.4.20
* PHP 5.4.x
* MySQL 5.5.x

Any ideas or next steps for troubleshooting would be most appreciated.

# Answer
this seems to point at a broader drupal problem. is there something you've changed recently on the server? eg. updating php?

does the rest of your drupal site work ok?
> 2 votes

---
Tags: civimail, error, php, tracked-links
---


# Question
Title: WP sidebar replicated in dashboard window
Any ideas on why one user may be seeing the WP sidebar replicated over the dashboard. This happens on all browsers (IE, Firefox, Chrome) it only happens for the one user. Her WP role is the same as other users.

Functionality of the rest of the application is fine except for this annoying 'extra' sidebar

# Answer
> 1 votes
Found the problem.

Firstly the screen in the image above is not fully loaded.

Once it had loaded the error message "custom field expected (0) found" which pointed to the report it was attempting to load in the dashboard being obsolete.

Deleting the report resolved the problem. :)

---
Tags: menu, wp
---


title: Error when trying to install buildkit

text:
# Question
Title: Error when trying to install buildkit
I am trying to install buildkit and re-educate myself with some of the more up to date CiviCRM development practises :-) However, I get an error when I run civicrm\_download\_tools. I am running Ubuntu 14.04. Here is what my npm-debug.log says:

```
 14868 error 404 'types' is not in the npm registry.
14868 error 404 You should bug the author to publish it
14868 error 404
14868 error 404 Note that you can also install from a
14868 error 404 tarball, folder, or http url, or git url.
14869 error System Linux 4.4.0-57-generic
14870 error command "/usr/bin/nodejs" "/usr/bin/npm" "install"
14871 error cwd /home/erik/buildkit
14872 error node -v v0.10.25
14873 error npm -v 1.3.10
14874 error code E404

```

Any ideas what I could or should do?

# Answer
Solved by updating my npm install using

```
install npm -g

```
> 2 votes

---
Tags: developer, civicrm-buildkit
---


# Question
Title: Edit button and allowing some users to edit subtype
I've removed the main Edit button from the top of the contact record (using CSS) because it confuses people.

Almost everything can be edited by hovering over it, with the exception of contact subtype and external ID.

We don't edit external IDs but some people need to be able to change contact subtypes.

The people who edit subtypes could easily cope with the "global" edit button being there without getting confused.

Can anyone suggest a way of showing / hiding the edit button by role or group? Or any other solution to allow some users to edit subtypes, while not showing the global edit button to everyone?

# Answer
> 4 votes
What CMS are you using?

In Drupal, an easy way to do this would be to add a Block, shown conditionally by role, containing your css.

---
Tags: drupal, css, contact-types
---


# Question
Title: CiviDiscount Navigation URL broken on Joomla
After upgrading to Joomla 3.6.5 (from, I forget which - should have made a note) the CiviDiscount navigation URL is broken (sends me to the CiviCRM dashboard). I also did a more minor update of CiviCRM to 4.7.14 (from 4.7.10ish) immediately after.

This question deals with a similar problem in Drupal. This is the URL that I am sent to from the menu: http://\[site\]/administrator/?option=com\_civicrm&task=civicrm/cividiscount

What should it be instead?

# Answer
> 0 votes
After I discovered that the CiviVolunteer menu URLs were also broken, I updated to the most recent version of CiviVolunteer. That fixed the CiviVol broken URLs, and the CiviDiscount URL is also fixed.

---
Tags: cividiscount
---


# Question
Title: What should be entered in the campaign field when importing a CSV file?
I'm trying to import a CSV file with donations that need to be linked with a certain campaign. I tried putting the campaign name, then the external id, and even just "matching" but all of them are generating an error. Any advice?

I am running CiviCRM 4.6.19 on Drupal. The error message is:

> 'xyz' is not a valid option for field campaign\_id

# Answer
> 2 votes
I was able to successfully import the campaign on a contribution by importing the campaign's CiviCRM ID.

I agree that it seems odd that campaigns have an "External ID" field, but it can't be used for imports, though!

You can find your campaign IDs by going to **Campaigns menu » Dashboard » Campaigns**. In CiviCRM 4.7+, they'll be in the first column of the list. See screenshot 1 below. If you're using CiviCRM 4.6 or lower, you can find the ID by hovering your mouse over the "Edit" button next to a campaign and reading the ID that appears in the URL at the bottom of your web browser. See screenshot 2 below.

# Answer
> -1 votes
Is the campaign currently active or was it started before the dates your importing? I'm just throwing out a possible reason why it fails. I do not know if this would make or break the import.

---
Tags: custom-fields, import
---


# Question
Title: Sorry but we are not able to provide this at the moment. DB Error: no such field Return to home page
I have created profile forms, using custom fields, which open up perfectly in create mode but when I test the forms I get this error once I hit save:

> Sorry but we are not able to provide this at the moment. DB Error: no such field Return to home page.

Any ideas of how to solve this?

Here is a link to one of the forms in question: http://skillsguru.web.za/civicrm/?page=CiviCRM&q=civicrm/profile/create&gid=21&reset=1

The detailed debugging report is here.

# Answer
> 1 votes
Based on the error in the debug message, the problem field is this one: `civicrm_value_developing_an_accredited_course_5.provide_instructions_on_any_furt_119`

I can't find it now, but there was a bug report recently that discussed problems with very long custom field names. Please find your custom field with an ID of 119 and see if the form works when it's removed (or at least see if the MySQL error changes). Consider recreating those fields with shorter names - you can always display them with the longer "names" in the profile's field label.

---
Tags: profile, error
---


# Question
Title: How can I set up registration and payment for an ongoing event that happens every saturday
the event happens every Saturday of the year, rain or shine with a limited participant number.

The fee is based on household so many people can be registered under one registration. So I'd need to sign up several people to one payment. But also have the event close once he max participation is reached

Thank you!! :)

# Answer
This question has a lot of aspects. I will focus on the fact that the fee is based on the household. Does it mean that the household is your actual customer and that you are not interested in the details of the participant? And you only want to prevent that the event is overbooked? If this is the case you can use Price Fields.

* Create as part of a Price Set a Price Field set a Text/Numeric Quantity field (in my example Seats).
* Enter the participant count, make this 1 (see (1)).
* Set the price on 0.00 (this field is only used to track participants see (2)).
* Uncheck the Display Amount option.

Now in the online registration form you can enter a number in the Seats field and this will add up to the total number of participants.
> 2 votes

# Answer
If you want the individual family members to be counted towards the event total (ie your limit is 200 people rather than 50 families) then it sounds to me like you need to use a Price Set with 2 fields

One is a 'select' field and provides the cost for the family eg $50

The second is "Text / Numeric Quantity" and has the Participant Count set to 1 (per unit(

So Mary comes along, gets charged $50 for the Family ticket, and then enters 7 in the next field, and that way 7 participants are added to the 'count' of participants.
> 2 votes

# Answer
Others have covered have to handle the payment and max registration. To have this event happen every weekend, you'll want to select the "Repeat" tab:
> 2 votes

---
Tags: civievent
---


title: Where is CiviCRM installed?

text:
# Question
Title: Where is CiviCRM installed?
I have CiviCRM installed on my web site, and some answers on Stack Exchange tell me to change a file in CiviCRM, or to find my "civicrmroot". I know how to access the files on my server, using FTP or SSH or my control panel's "File Explorer". However, I don't know where to look for CiviCRM. Where is it?

# Answer
If you're using CiviCRM 4.7 or higher, you can find this location by going to **Administer menu » System Settings » Directories**. Click the blue circle with the question mark, and note the value for \[civicrm.root\]. See screenshot:
> 5 votes

---
Tags: files, filesystem
---