# Question
Title: When will 4.4 LTS end, and what will replace it?
Official support for CiviCRM version 4.4 as a Long Term Support (LTS) version began in the fall of 2014. When will it continue to, and which version will become the next LTS?

# Answer
> 7 votes
4.6 will be the next LTS version. The switch from 4.4 to 4.6 will probably occur at the end of 2015, since the 4.6 branch will be quite stable by then.

---
Tags: lts
---


title: How to reset the menu items to defaults

text:
# Question
Title: How to reset the menu items to defaults
On a site where an old admin has moved all the menu items around, is there a simple way to reset the menu items to the defaults like you'd see if you installed CiviCRM fresh?

# Answer
Inside the CiviCRM root directory is a "sql" folder, and inside that is "civicrm\_navigation.mysql". Copy it to "civicrm\_navigation\_restore.sql" and edit the copy to remove all of the SQL commands EXCEPT this one: `SELECT @domainID := id FROM civicrm_domain where name = 'Default Domain Name';`

and any that start with `INSERT INTO civicrm_navigation`.

Change the `SELECT @domainID` line to read: `SET @domainID = 1;` (assuming this isn't multi-site).

Then run (after first backing up your database!) `DELETE FROM civicrm_navigation`.

Finally, run `mysql -u myusername -pmypassword databasename < civicrm_navigation_restore.mysql`.
> 7 votes

---
Tags: menu, admin
---


# Question
Title: How Do I Fix Mail Send Stopping at 500 Sends?
When using Civi Mail, we have a recurring issue wherein the system stops sending emails at 500 sends. The job shows as incomplete.

It is not a php timeout, as the hosting company (https://www.rochen.com/) has increased all our limits during testing, with no change.

We can re-initiate the mail send, and it will send out the next set of 500 emails, then stop again. We have to continue manually triggering the send to get the full job completed.

Any thoughts on the culprit?

System info: CiviCRM 4.2.6 Joomla 2.5.28 php 5.3.29 MySQL 5.5.42-cli

# Answer
Check **Administer menu \> CiviMail \> Mailer Settings**, and see if the "Mailer Batch Limit" is set to 500.
> 11 votes

# Answer
Sounds like a cron/scheduled tasks issue.

CiviCRM has a scheduled tasks system to organise jobs that need running at regular intervals. This in turn requires that something pokes it into action frequently (e.g. every 15 mins). Typically on Linux this is done with the system's cron utility.

Without CiviCRM being given chance to run its scheduled tasks, it will only ever do one batch - there's nothing to give it chance to run a second batch.

Setting this up is detailed in the book and on the wiki.

In brief, if you're on Linux + Drupal hosting, then you want a line like this in `/etc/crontab`

```
*/15 * *   *   *   <USER>  umask 0002; /usr/bin/php /var/www/your.civi.site/sites/all/modules/civicrm/bin/cli.php -j -s <example.com> -u admin -p '<DATABASE PASSWORD>' -e Job -a execute

```

Nb. you might like to put those commands in another shell script and then just reference that so as to avoid your database password entering your syslog.
> 9 votes

---
Tags: civimail, joomla
---


# Question
Title: Creating a custom search to produce contributions as results
I've followed the documentation to create a custom search and I find this capability to be quite powerful for finding and displaying information about contacts.

Now I would like to create a custom search to show a specific set of *contributions* and then (most importantly) allow me to perform actions on those specific contributions (e.g. "export contributions", "send thank-you letters").

Is this possible? If so, how?

# Answer
Start with the code for Find Contributions (https://github.com/civicrm/civicrm-core/blob/master/CRM/Contribute/Form/SearchContribution.php) and customize it as necessary to get the results you want, eg by hardcoding some values.

Next, choose a task similar to what you want to do from the list at https://github.com/civicrm/civicrm-core/tree/master/CRM/Contribute/Form/Task, and copy and modify it as necessary. Next, after reviewing https://github.com/civicrm/civicrm-core/blob/master/CRM/Contribute/Task.php, find a hook like buildForm to modify the search form so it includes your new task(s).
> 5 votes

---
Tags: contributions, custom-search
---


# Question
Title: How can I include Profiles on Drupal user registration?
I have a current Drupal and CiviCRM installation running LoginToboggan, Panopoly and Multiple Register.

I can toggle the original *Name & Address* Profile included with the installation, but when I set the checkbox for *Drupal User Registration* to true on the custom Profile Settings page, the form doesn't appear on the Drupal User registration form.

```
user/register

```

**Additional registration forms built with Multiple Registration**

```
register/supporter
register/volunteer

```

Clearing cache and running has no effect.

What's the best way to debug this problem?

# Answer
My guess is the problem is with Multiple Register since many folks have integrated LoginToboggin and CiviCRM. Turn off all of the three Drupal modules you mention, then reenable them one at a time to isolate which is causing the problem.

You can probably benefit by examining the source of the page with and without the troublesome module enabled in your browser using Firebug or something similar. You may end up needing to provide a patch to Multiple Register or making a custom extension in CiviCRM to help CiviCRM and Multiple Register play nicely with each other.
> 2 votes

# Answer
This isn't possible with Multiple Registration because they don't use the standard user/register page (and I'm guessing they override the core user/register functionality). You would need to hack or override civicrm.module. Below is relevant code from the module showing how it checks the path, note how it only understands "user/register", and "admin/people/create":

```
  // check for either user/register or admin/people/create
  $register =
    ((arg(0) == 'user' && arg(1) == 'register') ||
    (arg(0) == 'admin' && arg(1) == 'people' && arg(2) == 'create')
  ) ? TRUE : FALSE;
  $userID = NULL;
  if (!empty($form['#user'])) {
    $userID = CRM_Core_BAO_UFMatch::getContactId($form['#user']->uid);
  }
  $errors = CRM_Core_BAO_UFGroup::isValid($userID, $form['#user_category'], $register);
  if ($errors && is_array($errors)) {
    foreach ($errors as $name => $error) {
      form_set_error($name, $error);
    }
    return FALSE;
  }
  return TRUE;
}

```
> 1 votes

---
Tags: drupal, registration, profile
---


# Question
Title: How to make an efficient to-do-workflow for back-end staff?
CiviCRM is very flexible, to be able to be adjusted to the needs of many different use cases. One thing that is not set up by default, but is very helpful, is to set up to-do-lists for staff member.

**What is the best practice for setting up a to do workflow?**

(On the site I am administering, we have separate reports, showing for scheduled and pending activities last three months, with a certain assignee name. These reports are displayed on the dashboard of each user. At the same time the cron job will send by email daily reports with only the scheduled activities. So, each user can change the activity status from scheduled to pending, to indicate that they are working on it.)

# Answer
We've set up custom reportlets on dashboard that list the upcoming activities for the current user ordered by due date.
> 1 votes

---
Tags: user, best-practice, workflow
---


# Question
Title: How can we avoid staff users overwriting emails of utility WordPress accounts when testing CiviContribute pages?
I installed the latest CiviCRM on WordPress. WordPress is set up to refuse new accounts to the public, and there are about 12 utility admin/editor related accounts not tied to a specific person: AdminCrm, Editor, Staff1, Staff2, etc.

There is an ongoing problem if the logged-in user uses or tests a contribution page, because CiviCRM mixes up the current WordPress login with the user's contact information. The person logged into WordPress is invariably a member of the organization, and if they renew their membership while logged into one of these utility accounts, the email address for the renewal is copied from that of the *current* login which results in a duplicate contact created.

It would be nice if there was some way to turn off this behavior. I think CiviCRM on Wordpress was designed to assume contacts were always linked to a Wordpress login. Need suggestions on how to handle this day-to-day.

# Answer
> 8 votes
You should also consider giving your staff their own personal user accounts for a number of reasons.

* It will be clear that they're acting as themselves rather than as a generic staff person
* You can isolate the culprit(s) who are recording memberships the wrong way (see Jon's answer), meaning they don't cause problems for others and you can talk with them specifically
* When people leave the organization, change roles, etc. you don't need to change the password for everyone

# Answer
> 7 votes
Ideally, the day-to-day workflow of entering contributions/memberships for your staff should be to use the back-end forms, not the front-end forms, so you don't experience this. However, to help with this transition, you may want to consider installing the "no overwrite" extension, which prevents the problem you're describing: https://civicrm.org/extensions/no-overwrite

---
Tags: wordpress, cms-integration
---


# Question
Title: What should be best practice when creating custom fields?
When creating custom fields, and custom field groups, I have fallen into two pit falls.

First, the name of a custom field should not exceed a certain length, causing malfunction in the SQL structure.

Second, values should be unique. Of course, you would say, but look at this example: values: 1,2,3,4,5,6,7,8,9,10,11,12. When showing the values in a report, the 2 will show for both 2 and 12, and value 1 will show for 1,10,11 and 12.

The question is, what things should be considered when creating custom fields?

# Answer
If you find yourself wanting to give really long custom field names, think about whether you really should have a fairly short label and then provide help text that goes along with the field.

Besides causing database problems (though CiviCRM largely handles that on its own by just cutting off the field name), you'll have trouble displaying a super-long field name on forms and in reports.

For values, are you actually experiencing this problem? If multiple choices are allowed in a field (let's say all those numbers are available as checkboxes), they're separated by a delimiter character in the database. Searching for 2 won't pull a contact with 12, and searching for 12 won't show results that have both 1 and 2.

In the field itself, the storage is like (not with an asterisk but an unprintable character) "\*1\*2\*6\*" for having 1, 2, and 6 checked. It's stored like "\*11\*12\*" for having 11 and 12 checked. They're easily distinguished.
> 5 votes

---
Tags: custom-fields, best-practice
---


# Question
Title: How do we preprocess CSV columns when using CiviCRM builtin import functionality?
We use CiviCRM's import data functionality (and api-csv-import-gui) to import partner's contributions from CSV files. This is working great because the CSV columns can be mapped to CiviCRM fields via a graphical user interface.

However, we've recently had the need to preprocess one of these fields and transform their data on import. This process can't be done outside CiviCRM for security reasons.

Can I still use CiviCRM's point-and-click mapping functionality while being able to preprocess a specific CSV column in PHP? Unfortunately I can't just map the columns-fields in code because the CSV columns change.

# Answer
One possibility could be importing the data as it is (maybe using a temporary field for that column) and use hook\_civicrm\_post() to manipulate the contribution just after creation:

```
function example_civicrm_post($op, $objectName, $objectId, &$objectRef) {

  if ($objectName == 'Contribution' && $op == 'create') {

    if (!empty($objectRef->temporary_field)) {

      // Preprocess field. FIXME: do some validation first.
      $objectRef->real_field = do_awesome_stuff($objectRef->temporary_field);

      // Clear temporary field.
      $objectRef->temporary_field = '';
    }
  }
}

```
> 3 votes

---
Tags: civimember, import, civicontribute, hooks
---


# Question
Title: How to disable cache refresh on Manage Groups page
The Manage Groups page in Civi 4.5+ displays counts of contacts in each group, and in the process refreshes the smart group contact cache. We've turned off this cache elsewhere as it takes 10mins to complete (we have a *lot* of groups) - but the Manage Groups page seems to force a refresh. Is there a way to disable this refresh?

I can't see a setting, so am assuming it'd involve commenting out some code. I found the code in Contact/BAO/Group.php that I think disables the *count* of the contacts, but can't figure out where the cache-refresh itself takes place.

# Answer
The manage groups page does not force a refresh of the smart group cache but there is a button to do so on the right-hand side:

Without clicking that button, what it does do is count the number of contacts already in the cache, but this query has been optimized and tested against a very large (6 million group\_contact records) database.

You'll find more information at https://issues.civicrm.org/jira/browse/CRM-15107
> 6 votes

---
Tags: groups, smartgroups, cache
---


# Question
Title: Can I expose CiviCRM contacts to Drupal Linkit?
We have an intranet for a small membership organization with a wiki done in Drupal 7 and a CiviCRM 4.5 installation for member information. Everyone with access to one has access to the other, so we looked into the idea of linking directly to CiviCRM contacts from the wiki as appropriate (e.g. "for ad hoc reports, contact Nilesh").

Linkit is a Drupal module that makes it easy to insert links into content, whether through a WYSIWYG editor or at the field level. To simplify, it provides an autocomplete field that allows the content author to choose from possible destinations, then automatically generates the canonical link. This would be ideal for authors, to avoid having to look up CiviCRM contact IDs.

According to the module page,

> Linkit links to nodes, users, managed files, terms and have basic support for **all entities by default**.

(emphasis in original). It does not, however, interface with CiviCRM contacts that should be recognized as Drupal entities when CiviCRM Entity is installed and active.

Is the fault here on CiviCRM Entity or on Linkit? Is there a better practice for linking CiviCRM contacts from CMS content?

# Answer
> 3 votes
Have you tried the CiviCRM Contact Reference Field module? It ships with Core but needs to be turned on separately.

---
Tags: drupal
---


# Question
Title: Is it possible to apply an existing contribution to an event registration?
My client runs camps which require a minimum $50 deposit. Campers send one or more additional payments until their registration is paid in full. Since CiviEvent doesn't support self-service for partial payments, we're considering not charging on the event registration page (set Pay Later and hide it), then redirecting the registrant to a contribution page after confirmation. A back office user will then apply that contribution to the pending registration.

I've tried editing registrations and contributions, but can't find a way to link them up after the fact from either direction.

# Answer
> 4 votes
Self service for supplementary payments for event registrations is not yet available in CiviCRM as of version 4.6.

As you likely know, it is possible to manually edit registrations to record additional payments, and to view all payments that have been made against a registration. When doing this it is possible to record notes to help document what is being done. As a work-around perhaps you could cancel the incoming supplementary payments of $50, and then apply them to the registration.

Alternatively, or in addition, we could set up a Make It Happen fundraising effort to get this into core.

# Answer
> 3 votes
I don't like cancelling payments, so I have created a payment instrument called "transfer". I edit the event registration to record a partial payment using the payment instrument "transfer" then record a negative contribution, again with the payment instrument "transfer", to balance it out.

As Shai says, "it's not a picnic".

---
Tags: civievent, civicontribute
---


# Question
Title: How to change CiviCRM Home to a different page (not Dashboard)?
For some use-cases the CiviCRM Dashboard is not a helpful home base. Many users find it disorienting if the available dashlets are not useful to them.

So my question is simple: How can the mysite.org/civicrm be set to a different default page?

For example, I would like mysite.org/civicrm to default instead to the page shown at mysite.org/civicrm/contact/search?reset=1 so that all menu links that point to "CiviCRM Home" would end up at /civicrm/contact/search?reset=1

# Answer
> 18 votes
Since this path is hard-coded into CiviCRM, the best way to override it is probably a redirect. You could achieve this:

Note that there are two paths you'd need to redirect from: `/civicrm` and `/civicrm/dashboard` as Civi treats the former as an alias of the latter and links do not consistently go to one or the other.

---
Tags: menu, dashboard, civicrm-home
---


# Question
Title: Change the default fields (columns) in contact search results
Very frequently I get users asking if we can remove Address/City/State/Postal/Country columns from the default search results table. Often they want to show some of our custom fields instead. Or to just remove clutter.

I know this is a common question, and I am aware of hook\_civicrm\_searchColumns and how to use profiles with advanced search.

But I am asking here to get verification that there is not a better way to simply remove some columns from the results of civicrm/contact/search

# Answer
> 13 votes
There is a non-code fix for this:

You could make a profile with the fields you want to display.

And then you search using Advanced Search, and you could select that profile in the "display result as".

Edit: As pointed out by Philipp Michael in the comments below, you could also choose a certain profile as the default one, in the admin settings ( at /civicrm/admin/setting/search?reset=1.)

---
Tags: search, default-settings, search-results
---


# Question
Title: Can we export from membership search and include fields for groups?
I'm managing a country-wide organization's membership database with 1 membership type (you're either a member or you're not). Each region or province/state is represented by a Group.

This allows us to create an online roster (membership listing) that can be filtered by the regions across the country.

All of the updates to contact records and membership records (renewals) are handled via CSV imports.

For improving the maintenance of the CRM information, my goal is to run a search memberships report for current/new members which I can then split by region. I can then send the exec-admins governing each region their piece of the report so they will have a unified spreadsheet for managing addition and updates to the members they govern, making imports smoother to update contact records and membership renewals.

The issue I am running into is exporting a membership CSV spreadsheet that includes the all important Group or Group ID number. Any thoughts?

# Answer
I've run into an almost identical problem, which I solved with a custom extension. I've hardcoded which groups correspond to chapters, and whenever someone is added to a group, I check if it's a "chapter" group. If so, I update a custom field with their chapter name, so I can export it. I could upload the entire extension to Github if you like, but the relevant code is here.

`function membershipcards_civicrm_post($op, $objectName, $objectId, &$objectRef) {
 //set the chapter name for membership cards
 if(($op == 'create' || $op == 'edit') && $objectName == 'GroupContact'){
 $params = array(
 'version' => 3,
 'sequential' => 1,
 'contact_id' => $objectRef[0],
 );
 $result = civicrm_api('GroupContact', 'get', $params);
 //cycle through the groups. If you find one that's a chapter
 //(currently hardcoded as gid <= 83), return its title.
 foreach($result['values'] as $key => $value){
 if($value['group_id'] <= 83) {
 $chapter = $value['title'];
 break;
 }
 }
 $params = array(
 'version' => 3,
 'sequential' => 1,
 'custom_98' => $chapter,
 'id' => $objectRef[0],
 );
 $result = civicrm_api('Contact', 'create', $params);
 }
}`
> 3 votes

# Answer
Groups is not available as a field when using the Member export. Note that it is available when using the contact export in case that is of any help but I guess not since given you are trying to do renewals via CSV you probably want to see membership fields in the export.

One 'lowtech' solution would be to do two exports - one of your membership data and one with contact data (potentially filtered to members) and then use a tool that can merge these two data sources. Pretty sure that Excel's vlookup function can handle that kind of thing quite easily but I don't really use it much.

Else you could commission someone (the core team for instance) to get the group field export added to the membership export.
> 1 votes

---
Tags: workflow
---


# Question
Title: How do I send mailings to subsets via the API?
This is a big question :-)

I'd like to be able to use the API to send mailings to subsets of groups.

What is the simplest way to achieve this?

Ideally I'd like to be able to define a subgroup using an SQL subquerey:

```
SELECT contact_id FROM {{mycustom tables}} WHERE {{my custom logic}}.

```

Alternatively my custom code could execute this sql and pass in an array of integer IDs: `[2344, 651234, 7212334, 123512... etc]` (but I'd rather the SQL filter)

We have a legacy mailer that uses custom logic to identify subset of people for distributed grass roots field organisers (GRFOs) to send emails to 10-200 people at a time.

We need a very simple mailer interface for our GRFOs as given their large number and the churn in the organisation we haven't found that exposing them to the full complexity of the CiviCRM has worked.

Combining this custom filtering with custom tokens (which we already have) and our own integrated simple mailer front ends would enable us to really rock-out with the CiviCRM mailer.

# Answer
> 3 votes
I have a suggestion for this :

In your custom code where you get the contacts use the GroupContact API and create a group and add those contacts to that group. And than using the Mailing API send the mailing by referencing that group. After sending you can delete that group. HTH.

# Answer
> 3 votes
Although I think the hidden group answer is the most maintainable, it may be useful to mention another approach. CiviMail in v4.6 includes an A/B testing feature which takes a list of recipients from one group and breaks it into three smaller groups (test A, test B, and final blast). This is very similar to your problem.

You can see how the MailingAB API implements this (on top of the Mailing API) at https://github.com/civicrm/civicrm-core/blob/4.6.beta5/api/v3/MailingAB.php#L109

Unfortunately, in v4.6, the underlying BAO code is a bit overzealous about managing the mailing-records (e.g. autopopulating schedule and recipient lists in a way that matches the original CiviMail UX); the MailingAB bypasses this with the option "'\_skip\_evil\_bao\_auto\_recipients\_" and then manipulates the recipients more directly (CRM\_Mailing\_BAO\_MailingAB::distributeRecipients()).

I would love see the API changed so that it's more flexible about creation-vs-recipients-schedule -- and almost did it myself in v4.6. However, the scraggly old bits are required to support the CIVICRM\_CIVIMAIL\_UI\_LEGACY option. The CIVICRM\_CIVIMAIL\_UI\_LEGACY option is scheduled for removal after v4.6, so that might be a good time for someone to clean it up.

# Answer
> 2 votes
I have created an extensions for sending e-mails through the API. Check https://civicrm.org/extensions/e-mail-api

A similair extension exist for sending sms through api and yes for printing pdf letters.

---
Tags: api, civimail
---


# Question
Title: What are the different cache clearing mechanisms relevant when developing?
When doing developpment, i sometimes found it difficult to clear all the cache in a way i'm sure everything i have done is taken into account.

Let's take some examples :

* in an extension, i do an override of some core .tpl file (i know i shouldn't do that but sometimes difficult to avoid) - will it work out of the box or do i need to clear some cache ?
* in an extension, i create a new page or form with a custom menu xml file - what do i need to clean ?

What are the different level of caches involved ?

Is there a way to clean all caches in one shot like the drupal `Flush all caches` / `drush cc all` ?

# Answer
> 15 votes
For the first example, you need to 1. clear the compiled Smarty templates cache. In the second case you need to 2. rebuild the menu system using your xml file. 3. There are some db cache tables you sometimes need to clear out using mysql or a link in the UI. 4. Caching in the CMS can also affect CiviCRM pages.

1. a) One way to do this is to go to Admin \> System Settings \> Cleanup Caches and Update Paths (civicrm/admin/setting/updateConfigBackend?reset=1), then click Save.

b) A more convenient method during development is to be able to append arguments to the url you are debugging to have the cleanup done automatically. Go to Administer \> System Settings \> Debugging and Error Handling.

Click to Enable Debugging. At this point you can add a key-value pair to your URLs to clear the compiled Smarty file cache under templates\_c, and also if you want the upload file directory: Directory Cleanup -Empties template cache and/or temporary upload file folders. To empty template cache (civicrm/templates\_c folder), add &directoryCleanup=1 To remove temporary upload files (civicrm/upload folder), add &directoryCleanup=2 To cleanup both, add &directoryCleanup=3

You might also want reset the session, since that caches various values: Session Reset - Resets all values in your client session. To trigger, add &sessionReset=2

2. a) Enter the appropriate one of the following urls to rebuild the menu system, which also clears various caches:

Drupal sites: http:///index.php?q=civicrm/menu/rebuild&reset=1

Joomla 1.5 sites: http:///administrator/index2.php?option=com\_civicrm&task=civicrm/menu/rebuild&reset=1

Joomla 1.6 sites: http:///administrator/index.php?option=com\_civicrm&task=civicrm/menu/rebuild&reset=1

Wordpress sites: http:///wp-admin/admin.php?page=CiviCRM&q=civicrm/menu/rebuild&reset=1

This action also resets the IDS (intrusion detection system) file.

b) As explained in @Tim Otten's answer, this can be done conveniently from the commandline as well, using a better named wrapper for the same actions:

In Civi-Drupal, the analogous command is: $ drush cvapi system.flush

In Civi-Wordpress, it's: $ wp civicrm api system.flush .

Or alternatively, in Firebug's CLI: CRM.api3('system','flush'))

3. There are other sorts of caches that may occasionally need to be reset. a) At Contacts \> Manage Groups, it is possible to reset the caches for contacts that are in Smart Groups by clicking near the top left of the page the Update Smart Group Counts link.

b) More generally, depending on the area of CiviCRM you are working on you may need to truncate any of the CiviCRM tables that have cache in their name:

```
mysql> show tables like '%cache%';
+-------------------------------------+
| Tables_in_clubcdn_civ_new (%cache%) |
+-------------------------------------+
| civicrm_acl_cache                   |
| civicrm_acl_contact_cache           |
| civicrm_cache                       |
| civicrm_group_contact_cache         |
| civicrm_prevnext_cache              |
+-------------------------------------+
5 rows in set (0.00 sec)

```

Use TRUNCATE civicrm\_acl\_cache; or similar queries on the command line or in phpMyAdmin to clear these tables.

4. CMSes have their own caches that can often cause grief when developing in CiviCRM. For example, in Drupal 7, go to Configuration \> and in Development set of modules click on Performance. Click to purge the caches. You might also want to disable caching of pages for anonymous users, caching of blocks, and / or aggregrating and compressing css and javascript files.

# Answer
> 9 votes
+1 for Joe's comment which is pretty thorough.

Re: `drush cc all` -- this command can be pretty important in the workflow for Drupal dev. In Civi-Drupal, the analogous command is `drush cvapi system.flush` In Civi-Wordpress, it's `wp civicrm api system.flush` . (Or, if you're more into Firebug's CLI, `CRM.api3('system','flush')`)

Note: Despite the anachronistic naming, "/civicrm/menu/rebuild" is basically the same thing, and so is "/civicrm/clearcache". Internally, all of these commands are wrappers for `CRM_Core_Invoke::rebuildMenuAndCaches()` (aka the grand-daddy of all flushing functions in Civi).

If there are any caches in the civicrm-core codebase that are omitted by `CRM_Core_Invoke::rebuildMenuAndCaches()`, then that's a bug, and patches to flush more caches would be welcome.

---
Tags: extension, developer
---


# Question
Title: What is the best approach for using CiviCRM as an app on mobile?
What extension is by now the most succesful in displaying CiviCRM content in a mobile app?

(If you have any personal experiences, please tell about them...)

# Answer
> 5 votes
The combination of the two extensions CiviMobile (thanks @rahulbile) and Summary fields is very interesting.

The CiviMobile extension is poorly documented, but after a while I figured out that it uses profiles to choose which fields to display. Also different profiles for each contact type: Individual, Household and Organizations. It took me more time before I figured out that it used the restricted profile\_ids 4, 5 and 6, which can be edited to add more fields.

Then I could also use some of the fields from Summary fields, to display relevant contribution informations as search result on the contact.

# Answer
> 1 votes
I don't think that apps are as common as using responsive design for the site and then creating special pages that don't put too much onto page.

# Answer
> 0 votes
We have found the Extension CiviMobile quite good. Have you checked it ?

---
Tags: extension, mobile
---


# Question
Title: Quick search icon spins forever after upgrading from 4.4 to 4.5
The upper-left quick search box and the edit-in-place for contacts spin the loading icon forever but never do anything. Looking in the browser console, there is a JavaScript error. It worked just fine on 4.4 but stopped after the upgrade to 4.5. I'm using the latest version of Drupal 7 in a multi-site setup.

# Answer
> 3 votes
Since you're using multi-site Drupal, check the Image Upload URL in Civi to be sure it's not set to https://\[domain\]/sites/default/files/civicrm/persist/contribute/. In a multi-site setup there is no such thing as a 'default' site.

The quickest way to determine if this is your problem is to visit the CiviCRM dashboard and check the browser console for a 404 error on arrow.png. You will notice that the URL to the png file starts with https://\[domain\]/undefinedpackages/. Or try to use an ajax-powered feature and receive a JS error like "'back' is undefined".

# Answer
> 1 votes
For reference, here are some troubleshooting steps for fixing non-responsive ajax or broken javascript in CiviCRM.

---
Tags: drupal, ajax
---


# Question
Title: What is the best way to add a contact to existing membership using relationships?
I'm having trouble with adding additional contacts to memberships (CiviMember). The goal is to add spouse, partner, sibling, etc. to an existing membership. The membership type is our own custom type, *Household* (not the contact type), and I guess I should have set a relationship type when I created it. I can't change the relationship type now; the UI blocks this since the type is in use.

The book's description for this is extremely terse and I can't understand how relationship type works, I have no idea what to expect, it's all cut-and-try. A working example would be great if one exists somewhere.

# Answer
From your description it sounds like you want to have a membership type that applies to a household and which subsequently applies to any individual with a given relationship to that household (probably the "Household Member is" relationship).

To make this work it needs to be set up before you have any memberships in your database. As soon as one of these memberships is applied to a contact, you can't then change the relationship element of the membership type.

From your question it sounds like this is where you are: you've created the membership type but not set the relationship, and then you have created a membership for one or more contacts and so can't now edit the relationship settings for the membership type.

How to get round this? One option that might be workable subject to the volume of memberships that you might need to edit could be as follows:

Create a new membership type that matches the settings of your current membership type, but add in to it the required relationship setting.

Then you could go through each of your contacts that has one of the original memberships, and edit it to remove the original membership and add the new membership (the one with the relationship setting in place).

Then any related contacts would automatically have the membership applied via that relationship. As I say this approach could be workable if you don't have too many records with the old membership, otherwise it might not be a sensible manual task, and an alternative approach, such as manipulating the database directly, or via the aPI, might be more suitable.

To add a relationship setting to your membership type, you need to decide which relationship is the right one. This is not necessarily intuitive, but depending on the version of CiviCRM you are running, there may be a useful pop-up help window when you click the question mark icon.

It reads:

"Use this field to configure Membership Types where memberships are automatically granted to related contacts. Examples:

Relationship Type: 'Household Member is'

Direct member is: a household

Membership is automatically granted to: 'Household Members' of that household"

I think that might fit your particular requirement. If required you can also optionally set a maximum to the number of these related memberships that are allowed. For a household this might not be particularly relevant, but is often useful when the direct member is an organisation.
> 2 votes

---
Tags: 4.5.6, relationships, civimember
---


title: Using <div> tag for pdf printing

text:
# Question
Title: Using <div> tag for pdf printing
I have made a html-template in CiviCRM consisting only of this kind of html tag: \<div style="position: absolute;"\>

This works perfect for selecting a template for pdf printing, when printing only one page. Then I have the opportunity to place certain elements at the appropriate place on my letter.

The problem arises, when selecting a bunch of contacts, and then creating pdf-s to all of them at the same time. Then it only prints all on one single pdf-page, instead of one page pr. contact. I want the CiviCRM-template to print the \<div\> tag on one page pr. contact.

Is there a trick here I don't know? And if so, please explain...

(My site is using wkhtmltopdf to generate the pdf-s)

# Answer
> 3 votes
I figured it out on my own. To print `<div>` on different pages, it needs to be positioned relative.

So, I ended up putting all the existing `<div>` with position absolute into a `<div>` with position relative.

However, that is not sufficient enough, I also needed to fill in a simple `<br />` tag as well.

This worked:

`<div id="page" style="position: relative;">`

`<br />`

`<div id="content" style="position: absolute;">`

`</div>`

`</div>`

---
Tags: templates, pdf, html
---


# Question
Title: How can I import Memberships without e-mail addresses or external IDs?
We are transitioning a small organization to CiviCRM 4.5, with about 2000 total contacts and about 150 memberships. The contacts imported without any problem, but when we went to import the memberships, we found that CiviCRM required either an e-mail address or an external ID.

About half of the members do not have an email address, and since the old membership system was a combination of Excel files and offline physical media, they have no unique membership numbers or other identifiers. All of the firstname+lastname combinations are unique, so we thought that should be sufficient, and we have the deduplication rule set to that effect elsewhere, but it seems to be inadequate for membership imports.

We don't want to be in the business of creating dummy email addresses, so it seems we must manually assign an external ID to the old contact list *and* the membership list, then reimport both in turn. But is there an easier workaround— some way to use Firstname+Lastname as the unique identifier? Or is there another "best practice" we could adopt here?

# Answer
> 5 votes
Here's an idea:

1. Import contacts (as you have already done)
2. *Export* the contacts you just imported, selecting the at least the following fields: contact ID, first name, last name
3. **Use spreadsheet formulas** to match the ID up like this:

1. Add a new sheet in your memberships spreadsheet
    2. Paste in the exported data
    3. Add a new column to the *left* (can't be right) of your exported data, and call this column "name".
    4. Create and fill a formula for the name column to concatenate the first and last name (e.g. `=C2&" "&D2` will concatenate the contents of cells C2 and D2, with a space in between.)
    5. In your memberships sheet, create a new column called id, and create a formula like `=VLOOKUP(A2,Sheet2.A$2:D$10000,2,0)`.

    1. `A2` is for the column in your memberships sheet that contains the full name. If you have two columns, then you'd want to write something like `C2&" "&D2`, as we did before.
        2. `Sheet2.A$2:D$10000` is an absolute reference (dollar signs so it won't change when formula is filled downwards) to the range containing all the ID reference data. I wrote 10000, but make sure you use a number large enough to encompass the whole data set. Note that `Sheet2` is the name of the sheet.
        3. `2` is to say that the value you want to pull into your memberships sheet is the *second* column from the left in your ID data.
        4. `0` is to say that you want the VLOOKUP function to give you "#NA" if it can't find a match instead of the (terribly chosen) default behavior of picking the nearest match.
    6. Export memberships spreadsheet to CSV, and then try importing into Civi using the ID values that you pulled in

*(These formulas should be correct for LibreOffice, but may need to tweaking for MS Office, with which I'm less familiar.)*

# Answer
> 1 votes
If you have already imported all your contacts, then each one will have a unique CiviCRM ID. As you only have 150 memberships to take care of, it won't be a huge task to match the CiviCRM ID to the membership record (and with some Excel skills, which I don't have) it could probably be at least semi-automated. Then you can use the CiviCRM ID as the match field for your membership records.

http://book.civicrm.org/user/current/common-workflows/importing-data/ states that the CiviCRM ID or an external ID will do the job.

---
Tags: civimember, import
---


# Question
Title: How to tell which .extra.tpl files CiviCRM is trying (and failing) to load?
I was writing an extension which injects a template snippet, and was working fine. While working on the PHP, without any change to the snippet, it's no longer loading (the rest of the extension IS working). The template is at `<extensionname>/templates/Contact/Form/Contact.extra.tpl` (NOT in a "custom templates" folder - though if I move it there, it works). I realize I have absolutely no idea how to check which file locations CiviCRM is checking for its template files, is there a way to see?

# Answer
This code might help shed some light:

```
  $template = CRM_Core_Smarty::singleton();
  print_r($template->template_dir);

```
> 5 votes

# Answer
I think the real answer to this situation is: "don't use tpl.extra files in an extension". The reason is that there can be only one of them, and potentially many extensions. That little trick is really only suitable for in-house customizations, in which case you can stick it in the custom templates folder.

Here's some solutions to the same problem that do scale:
> 4 votes

# Answer
When I'm working with custom code in CiviCRM particularly with extensions, I'll turn on ***System Settings -\> Debugging***.

You can find it at the following URL: /civicrm/admin/setting/debug?reset=1
> 1 votes

---
Tags: extension, debugging, templates
---


# Question
Title: How to insert Javascript into an inline form edit via an extension?
Normally, if I want to inject a Javascript snippet into a form, I use a hook like in an extension like this: `function alternateduplicatecheck_civicrm_buildForm($formName, &$form) {
 if($formName == 'CRM_Contact_Form_Inline_CustomData'){
 CRM_Core_Resources::singleton()->addScriptFile( 'org.cpehn.alternateduplicatecheck', 'alternate_duplicate_button.js');
 }
 }` This works on most forms; however, this doesn't appear to work for forms used for inline editing loaded via AJAX. The hook is called, but the Javascript doesn't run. Maybe I need to modify my Javascript, insert an onLoad in there? It looks like:

`cj(function ($) {
 'use strict';
 console.log('hi');
 cj('.crm-button-type-upload').hide();
});`

Here's the AJAX request (it's a custom field set on the summary tab): `http://<sitename>/civicrm/ajax/inline?cid=5652&class_name=CRM_Contact_Form_Inline_CustomData&groupID=10&customRecId=339&cgcount=1&snippet=6&reset=1`

# Answer
`cj(function ($) {})` has an implicit document.ready. To unpack that dense few characters of code:

* `cj` is the deprecated alias of CiviCRM's copy of jQuery. In 4.5 and above use the new one: `CRM.$`.
* Passing a function straight into jQuery is an alias of calling `jQuery(document).ready()` (not one that we made up, it's a jQuery thing).
* The argument your function receives (`$`) is yet another alias of jQuery, which you should use inside your code block to make it more readable (so your code inside should be `$('.crm-button-type-upload...` not `cj(...`).
* So the whole thing, written out in full would be `CRM.$(document).ready(function($) {$('.crm-button-type-upload').hide();});` (not that I'm saying you can't use the shorter form `CRM.$(function($)...` I just wanted to make it clear what's going on)

To answer your question about how to include your js. As of 4.5, `CRM_Core_Resources` *will* add javascript files to snippets, and by default it does. I just tested it out and was able to get a script file loaded when I clicked to open an inline edit form on the contact summary page.

The only time this wouldn't work is if you specify the "header" region as the location for your script. This is because ajax snippets do not have a header.

You can find out more about loading javascript files and ajax at: http://wiki.civicrm.org/confluence/display/CRMDOC/Resource+Reference
> 4 votes

# Answer
I ran into a similar situation where my code would work in Firebug or Chrome JavaScript console but if I used cj(function(){});, the page level scripts were still loading and my code came in too early to have the page level scripts in scope.

In my case I used the following:

```
cj(window).load(function(){
    // your code
});

```

It's worth giving that a try.
> 1 votes

---
Tags: extension, hooks, ajax
---


# Question
Title: What is the root url needed for extension pages?
I've installed the API CSV import GUI extension extension which directs you to "go to the url civicrm/csvimporter/import" to go to the import page, but when I go to Mysite.com/civicrm/csvimporter/import I get an empty page.

I'm having a similar error with Civivisualize which directs you to go to "yoursite.org/civicrm/dataviz". In both cases I'm getting the a blank page.

What am I missing here?

=====

I'm on CiviCRM 4.5.5 and Wordpress 4.1.1

# Answer
The URL formula is different for each CMS. The most accurate approach is to open a CiviCRM page and examine its URL. For example, I logged into the public demo sites for v4.5, navigated to "Contributions =\> Dashboard", and the URL of each page:

All of these are displaying the same logical page, which is canonically identified as "civicrm/contribute". However, each CMS requires a slightly different prefix to it. You can construct URLs for other pages by swapping the "civicrm/contribute" part. So csvimporter's page (if it were installed) would be:

It doesn't seem like a good idea to ask an extension-user to figure out this URL by themselves. Instead, the extension should compute the URL and display it. This can be done with CRM\_Utils\_System::url() -- e.g. "CRM\_Utils\_System::url('civicrm/csvimporter/import')".
> 8 votes

# Answer
You may need to set up two things for your extensions, and you need to convert the shortform 'URL' provided into a full URL that goes to correct page under your CMS. The image appears to indicate you're running WordPress so I am using URLs for that CMS.

1. Navigate to Administer \> System Settings \> Directories (http://yourWordpressSite.org/wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/setting/path&reset=1). Copy the value from CUstom Files field to CiviCRM Extensions Directory field, and change the last level of the directory name from /custom/ to /extensions/ . The value will likely be /wp-content/plugins/files/civicrm/extensions/ . You need to create this directory and ensure it is writeable by the webserver process.
2. Navigate to Administer \> System Settings \> Resource URLs (http://yourWordpressSite.org/wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/setting/url&reset=1. In Extension resource URL, enter http://yourWordpressSite.org/wp-content/plugins/files/civicrm/extensions/

Once you are done this, the extensions should be working. Now you just need to navigate to their page. To do this on a WordPress site you need to insert the shortform 'URL' provided in your instructions into a specific part of the full URL for you site. While on a URL for a CiviCRM part of your site, replace everything from &q= to the end with the shortform 'URL', then append &reset=1 . The result should be something like http://yourWordpressSite.org/wp-admin/admin.php?page=CiviCRM&q=civicrm/csvimporter/import&reset=1
> 2 votes

---
Tags: wordpress, extension, urls
---


# Question
Title: Is there a CiviCRM hook or other method which can be used to push data updates to other systems?
We are attempting to keep two systems in live sync with each other, one is CiviCRM.

There are hooks in civicrm for:

**Pre database saving of data**

```
hook_civicrm_pre($op, $objectName, $objectId, &$objectRef) {}

```

and

**Post database saving of data**

```
hook_civicrm_post($op, $objectName, $objectId, &$objectRef) {}

```

but both functions are passed all of the data of the relevant form/group/profile that has been submitted rather than just data that has changed. i.e. civicrm considers all of the fields to have been updated even if it isn't the case.

Is the only option to go through each submitted field and compare the posted value to it's current value during callhooks\_civicrm\_pre? and then only update the 'other' system on callhooks\_civicrm\_post so that data that isn't actually saved isn't sent to the 'other' system.

Perhaps there is a better way, like a hook from the changelog?

# Answer
> 6 votes
In having to do this with Salesforce and CiviCRM a number operations included the creation of a new contact being initiated on one end, which then had to be replicated on the other. In this case we wanted to prevent both sending unnecessary data and creating duplicate contacts.

Whenever the data being synced didn't involve a chain of transactions that required the result of each previous one (like a primary key id), we used the log to create the data package as each row only contains the exact fields that were changed. In the other cases we did use the pre and post hook along with storing data in the session to create a package that was ultimately sent in the post hook. In both cases, only the data that was added or modified was sent, and not full entity records. We put the responsibility on the receiving systems to understand whether they were adding a new record or updating an existing one, based on certain characteristics of the data package.

Pushing this strategy let us take advantage of the cron and the bulk Apis whenever the data allowed it.

# Answer
> 5 votes
Unfortunately, there's no good one-step approach that I know of. Two options:

1. Use hook\_civicrm\_pre to trigger fetching the data from the database and stashing it somewhere prior to the change. Then, use hook\_civicrm\_post to compare the saved record to the stashed one and send the difference.
2. (The preferable way, in my mind) Just use hook\_civicrm\_post, send over everything, and then have something smarter on your remote system decide whether something has changed or not.

You might also consider the tradeoff in performance of deciding whether something has changed versus just saving everything, knowing that some things will be redundant. I suspect that you'll just take a small performance hit but save yourself a lot of headaches in making sure you accurately filter out which things are unchanged.

---
Tags: api, hooks
---


# Question
Title: How do I give event registrants one of four prices but allow admins to select a free option for guests?
I have an event signup form where I have four different price options. I have made this a mandatory field in order to require that registrants select one price option. However, when I as an admin user sign up a guest or volunteer, I would like there to be another option that does not cost anything.

Is there a way of doing this without also offering this option to the regular attendee? I cannot figure out how.

The workaround that we have is to add an additional field for admins with a negative amount to reduce the payment down to 0. This is not a great solution.

# Answer
I have accomplished this using the CiviDiscount module. It works well. You'll just need to create a code that offers a 100% discount and then only share this code with people whom you deem qualified for free registration.
> 5 votes

# Answer
CiviDiscount will work well for the use case. Another approach is to create a second price field that has visibility set to Admin.

This is the help for the field:

Fields with 'Public' visibility will be displayed on your Event Information page AND will be available in the online registration (self-service) form. For some events you may want to allow staff to select special options with special pricing and / or discounts (using negative price set field values). Select 'Admin' visibility for these Price Fields. They will only be included when staff or volunteers are registering participants from the back-office 'Register Event Participants' screen.
> 2 votes

---
Tags: civievent, forms
---


# Question
Title: Can a profile submission redirect to a PDF?
On CiviCRM 4.5/Wordpress 4.1, I'd like to create a profile that, when filled out, automatically downloads a PDF. Is such a thing possible? It didn't work when I put a URL to the PDF in the "Redirect URL" profile setting. Is there another solution that's end-user friendly? Could the Redirect Editor plugin be of assistance here?

# Answer
> 2 votes
How about redirecting the user to a page that has the pdf download link? Granted its not automatic...

---
Tags: wordpress, profile, redirect
---


# Question
Title: Can I update/requery a custom field that got changed via another field on the same page?
I created some database triggers that update a read only custom field that is displayed on the main contacts page. You change the value in another field and the db triggers update the custom field.

So how do I get that read only field to be refreshed with the new value or, at the very least, just refresh the entire page?

The civicrm ajax wiki page suggests CRM.refreshParent so I tried to put that in a post processing hook

```
function ccas_hooks_civicrm_postProcess($formName, &$form){
    if ( $formName == 'CRM_Contact_Form_Contact' or  $formName ==
             'CRM_Contact_Form_Inline_CustomData') {
        CRM.refreshParent;}
}

```

Of course, that didn't work. I ended up with following two error messages

Notice: Use of undefined constant CRM - assumed 'CRM' in ccas\_hooks\_civicrm\_postProcess() (line 300 of ...

Notice: Use of undefined constant refreshParent - assumed 'refreshParent' in ccas\_hooks\_civicrm\_postProcess() (line 300...

# Answer
> 3 votes
The contact summary screen is divided into different panes, and they are each refreshed separately. If a popup form needs to refresh one or more panes, it can specify them by jQuery selector. For example, the relationship form has this in its post-process function:

```
$this->ajaxResponse['reloadBlocks'] = array('#crm-contactinfo-content');

```

Which has the effect of refreshing the pane that contains, among other things, the current employer (which the relationship form may affect).

When you implement this in your form hook it will look like:

```
function ccas_hooks_civicrm_postProcess($formName, &$form){
  if ($formName == 'CRM_Contact_Form_Inline_CustomData') {
    $form->ajaxResponse['reloadBlocks'][] = '#crm-contactinfo-content';
  }
}

```

Or substitute/add the jQuery selectors of whichever other blocks you'd like to see refreshed. Note that this code uses the array append syntax rather than overwriting the entire array.

---
Tags: hooks, ajax
---


# Question
Title: How should I delete a CiviCase or a Case Type
If I need to delete a CiviCase Type or a CiviCase it can be confusing given that 'deleted' Cases are not actually removed from the db.

# Answer
Civi Case Types cannot be deleted while there are Cases of that Type. Cases can be changed to a different Case Type which can then permit you to delete a Case Type with no Cases. But if you just want the Civi Cases gone then note that Civi Cases themselves, when 'deleted', remain in the system for audit purposes. To delete a Civi Case entirely it is necessary to do so either via the API Explorer (at /civicrm/api/explorer) or via sql.

Via API Explorer use CRM.api('case', 'delete', {'id' : xxx});

Via MySQL use

```
DELETE c, ca, a FROM
civicrm_case c LEFT JOIN
civicrm_case_activity ca ON c.id = ca.case_id
LEFT JOIN civicrm_activity a ON ca.activity_id = c.id
WHERE case_id = xxx;

```

and this should take care of any case\_contacts data and any rows in civicrm\_relationships that have case\_id
> 6 votes

---
Tags: civicase
---


# Question
Title: How can I make it easier for users to generate the reports they need?
I am working with an organisation that uses CiviCRM to record information about their clients. They need to generate reports on a quarterly basis that summarise their work with clients. The reports need to segment the data by factors such as age range, gender, ethnicity, postcode etc.

None of the standard reports generate the information that they need so they use advanced search to obtain the figures for the reports. This gives them the information they need however it can be quite tricky to set up the appropriate searches. They also need to run the search several times for each age/gender/ethnicity etc.

Some examples of the types of reports they need (all figures are for the last quarter):

* number of clients referred - split by ward
* number of clients supported - split by ethnicity and gender
* number of clients supported - split by age range (e.g. 16-17, 18-19, 20-25, etc.)
* number of hours of support provided
* number of sessions delivered per ward

How could reporting be made easier for them?

# Answer
Another alternative is writing a custom report. It's not all that difficult, though it is writing PHP code. Even if you need to hire out for it, you'll have exactly what you need.

The details on how to create a report template extension are here: http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Report-Template+Extension

Most likely, you'll just need to take an existing report and make changes such as:

* adding an order\_by option in the \__construct() function for the fields that you want subheadings for
* adding a new table in the \__construct() function and creating the proper joins in the from() function
* doing some changes to how things appear by doing something in the alter\_display() function
* adding statistics for fields in the \__construct() function and defining them in the select() function
> 5 votes

# Answer
We have had great success using Jasper Reporting with CiviCRM.

It does require knowledge of the underlying CiviCRM database, and writing SQL against it, but the formatting capabilities are powerful and fairly easy to use.

Once a report is created, it can easily be added to the CiviCRM menu.

More details here: https://civicrm.org/blogs/lcarter/civicrm-and-jasper-reports
> 6 votes

# Answer
Since they're using Drupal, you may want to check out Forena Reports. There will be a session on using Forena Reports with CiviCRM at CiviCon Denver in three weeks.
> 5 votes

# Answer
If they are doing it all by using variations on advanced searches you could make a a custom searchand then (if you are in Joomla, but you can do the same kind of thing in Drupal or WP) make a module with the direct links to each one or give them a drop down.
> 4 votes

---
Tags: civireport, search
---


# Question
Title: Can I configure CiviDiscount for additional participants?
The CiviDiscount Extension page lists the feature "Option to apply discounts to additional participants" but I am having trouble finding that option.

I am curious if it can be extended (or used out of the box) for a workflow similar to this:

* First registration of a multiple person registration is full price
* Additional registrations (in the same multi-registration session) automatically get a discount applied

Has anyone used CiviDiscount with this feature?

---

*(Originally asked in the CiviCRM Forum)*

# Answer
> 7 votes
I don't think that you can use CiviDiscount for the work-flow you are describing.

CiviCRM does have another way of registering multiple participants, and that is with the use of price sets. You could use this to offer a discount. However, *this method would only be useful fo you if you don't need to collect any information about the additional registrants*.

If you went down the price set road, you would turn off register multiple participants on the event config, create a price set and and set your event fees to use this price set.

An example price set would look something like this:

* First price field: a required check-box set at $100 dollars (this handles the first registration)
* Second price field: a text/numeric quantity field set at $80 that increments the registration count by 1 (for all subsequent registrations)

**Note:** We are not using CiviDiscount at all in the price set example above.

**Aside:** "Option to apply discounts to additional participants" would probably be better worded as "Discounts can be applied to additional participants" in the documentation.

---
Tags: civievent, cividiscount
---


# Question
Title: How can I have a paid membership sign up that includes an option for a paid premium version?
Our primary membership sign up is via a dropdown list of options at different prices. Regardless of which option is chosen, we would like to give the sign-up person an option to upgrade (via an additional check box? to a premium version at a fixed additional price.

# Answer
This could be done by creating a price set with the premium option, and then using the civicrm\_post hook to make the change once the transaction was successfully completed in the DB.
> 3 votes

# Answer
Pretty much the only things you can do without coding are by setting up a price set with two fields. The first field would be the membership types in a select or radio list. The second field would be a checkbox field with one option. It could be a regular field without any membership tied to it, and you'd just be collecting extra money if someone selects it.

If you wanted to track an extra set of benefits, you might create another membership type with a different membership organization and tie the checkbox to that. The membership organization indicates that it's not an alternative to the main membership but rather a membership that you can hold simultaneously with the other one. It'll make your life more complex in some ways, but you'll be able to quickly see who's got the premium membership.
> 1 votes

# Answer
Although I don't think this will satisfy Dave T's need for something without any coding, the following would be my preferred way.

Let's say you have three membership types, each with premium/non-premium options:

* Student member
* Individual member
* Family member

You'd create six membership types in CiviCRM:

* Standard Student member
* Standard Individual member
* Standard Family member
* Premium Student member
* Premium Individual member
* Premium Family member

Then, set up a price set with two fields. One is radio buttons with one option per membership type. The other is just a single checkbox with no price (but a label saying "go premium for $100" or whatever). You add a bit of javascript to the form that does the following on page load and every time the checkbox changes status:

* if the checkbox is checked, show the premium options, see if one of the non-premium options is selected, select the corresponding premium option, and hide the non-premium options, or
* if the checkbox is not checked, show the non-premium options, see if one of the premium options is selected, select the corresponding non-premium option, and hide the premium options.

The result will be a single membership type, so it's easy to maintain, report, etc. However, from the member's perspective, the experience is one of an add-on rather than navigating among a bunch of options.
> 0 votes

---
Tags: contributions, civimember
---


# Question
Title: Is it a bad idea to change a Participant's registered event after a payment has been made?
I've been doing some thinking on this but haven't tested it yet. Essentially, we've a user who would like to *always* have the ability of changing Participants' events.

It seems as though the default CiviCRM functionality here is to allow changing events up until a payment has been made. That aside, it's still feasible to change the registered Event via API or otherwise.

I'm wondering is if there is a repercussion of changing the registered event after a Contribution has been made. Is this functionality disabled for the convenience of not having to worry about mismatched price sets or is there a deeper issue of breaking some kind of reporting functionality?

# Answer
> 1 votes
I think it's not there because it would need a fair bit of work to make it function well in all cases. I find that folks who have a lot of similar events are the ones who are most surprised it's not available. Part of it may be that their needs are simple (they don't have to deal with price differences), and part of it may be that they're more likely to have people switching between similar events.

The database side isn't too complicated. You'd need to update the table that aligns participant records and contributions, and then the contribution would appear to apply to the right event. I've even done this manually through the database for someone who was in a pinch and had a bunch of people on the wrong event.

However, you'd need to decide what happens when the paid amounts are different, the financial types for the two events' fees are different, and the meaning of the price options of the two events are different. For the latter, I mean this: what if someone wants to change their registration from the $200 ticket for the annual gala to the $200 VIP sponsor ticket for the picnic in the park? That information is in the price option selected, and you'd need to decide what happens when that moves.

Finally, there's the issue of partial credit or overpayment--when the prices aren't the same (as you mentioned).

Again, there are technical solutions to all of this, but the assumptions that one person may make aren't necessarily what the end user would make. A solution that goes into core needs to be reasonable for everyone.

What Joe mentions--a cancelled registration and a new registration--is almost certainly the way to go. You can do that now; the only real issue is when the bookkeeping shows a refund and payment that never really hit the bank account--you're just applying the credit for the one event to the new event. Automating that would be very convenient for many CiviCRM users, but it would also cause confusion and pitfalls for others.

# Answer
> 2 votes
From a bookeeping perspective it wouldn't be too hard to implement. But as it's not a frequent use case it may have not been implemented during the refactoring for CiviAccounts a couple of years ago.

Were we implementing this as a core enhancement I would want to ensure that scheduled emails work properly through this change of events. I wouldn't want to send any ones after the change that pertain to the old event, and I think the user should perhaps be warned about missing any scheduled events as a result of the change. For example, a mail scheduled for 2 days after registration in Event A may not go out if the change to that event is made made more than 2 days after the registration.

I don't foresee any reporting problems, but there would need to be regression testing. Basically, there would be one additional cancelled registration in the original event, and one additional registration in the new event.

---
Tags: civievent, contributions
---


# Question
Title: Custom payment processor for credit balance - need ideas and advice
Our organization maintains a "deposit account" or "credit account" for our constituents. Account balance info is stored in a 3rd party MS SQL application.

I would like to hear high-level ideas and advice on how go about building a custom payment processor so that folks can pay for CiviEvent fees, etc., using their credit account balance.

Has anyone encountered this situation before?

# Answer
> 1 votes
I would try grabbing the code for one of the current payment processors and creating a new instance of it for your credit account "processor". This should give you the plumbing necessary for CiviCRM; of course you will still need to build out the interface with the MSSQL application, but you will need to do that anyway.

To start this, do a 30 minute dive into the current civi payment processors... I recall there being some fairly simple implementations that you probably can most easily leverage.

---
Tags: payment-processor
---


# Question
Title: Wordpress CiviCRM groups, members and permissions
We are looking to use a Wordpress Multisite / CiviCRM integration and have a multisite development environment setup. We're not sure whether we should be using CiviCRM or Wordpress (or a combo) to establish permissions.

Here's a rundown of the user groups / permissions that we need to establish:

**BACKEND USERS**

1. Admin (2) - access everything, create new site

**FRONTEND USERS**

2. Committee member (10+) - add/delete documents specific to committees
3. State Manager (8+) - add/edit/delete members within the state. Add documents for downloading
4. Members (2500+) - when logged in can search for other members (all states), edit their own details and access private documents.
5. Public - access unrestricted content only.

**Q.** We want to limit access to the admin system to the Admins only and get State Managers to add/edit/delete **via the frontend**. Is this possible?

**Q.** We want committee members to be able to upload documents **via the frontend** that can only be viewed by other committee members. Is this possible?

**Q.** Can member login data (usernames & passwords) be stored in the CiviCRM or do all members need to be Wordpress users also?

**Q.** Would the Committee members be best setup as groups?

**Q.** Does anyone have a diagram of how the Members / Groups and other permissions work across a Wordpress integration?

# Answer
I can answer some of these questions:

* CiviCRM doesn't store usernames/passwords on its own. It integrates with the Wordpress authentication system
* You create user roles in Wordpress' User Role Editor. You can then go into CiviCRM and grant CiviCRM permissions based on Wordpress role.
* Because you say you want users to "upload via the frontend" and mention that they have logins - I assume you mean that these are users who have permissioned access to Wordpress, but not CiviCRM.

With CiviCRM, you should:

* Enable a user dashboard (to allow contacts to edit their own contacts);
* Create a search profile (to enable members to search for other members);
* Create ACLs (to allow you to restrict access to contacts based on their committee membership);
* Create several document submission profiles, to allow folks to submit/search documents that they're supposed to be able to see. I imagine I'd create a CiviCRM contact for each committee, then create a profile submission form that allows permissioned users to add activities with attachments to that user.

I could also see a different approach where the documents are stored in Wordpress and permissioned that way, but I don't know enough about Wordpress to know if that's feasible. I'm thinking of a feature similar to Drupal's Organic Groups.
> 2 votes

# Answer
Your question is very complex and you need to be very specific. I don't know what you mean by "via the frontend". For "admin" are you referring to WordPress admin or CiviCRM? We have sort of solved similar problems by adding a roles plugin in WordPress , and then creating additional custom roles, in your case: state manager, committee member, members, etc. Then we create WordPress users for each person that will login, and assign one or more of the custom roles to them. The logins are specific to a user, so you can see who did what on the system, and also avoiding mixups in the contacts table. All CiviCRM members (CiviMember) who login to the system will also be WordPress users as that's the only way to login. But members (CiviMember) in general do not have to be WordPress users, unless they need to login for some reason. (We do not allow public WordPress registrations on our system.) The CiviCRM admin permissions for the various WordPress roles are controlled via the ACL system in CiviCRM (Administer - Users and Permissions - Permissions). We setup each committee with a group definition in CiviCRM. I'm confused if you are mixing up WordPress users with CiviCRM members, they are 2 completely different things.

Some of your requirements are WordPress specific. You can upload documents and create pages to display them that are private; you must be logged in to see. The WordPress roles can be setup to have various levels of access to WordPress features, but this is outside of CiviCRM of course.
> 2 votes

---
Tags: wordpress, contacts, permissions, integration
---


title: How to compare CiviCRM to Salesforce?

text:
# Question
Title: How to compare CiviCRM to Salesforce?
I'm advising a small NGO and trying to figure out what is the best solution for them. Their data is essentially:

* client data: phone numbers, identification numbers, gender, etc.
* client-wise logs, e.g.: "January 1, 1970, 12:00 - contacted client foo and spoke with them on the phone regarding xyz. January 2, 1970, 13:00 - client foo contacted us and asked a question"
* appointment data: so-and-so has an appointment with this translator in that room at such-and-such a datetime.

Though I could maintain a custom piece of software myself, I think it's better if as much control as possible is put in the hands of the non-coders (not yet!) who are running the organization. In this situation, reinventing the wheel is probably not the right choice which is why I am considering CiviCRM.

There is discussion of using Salesforce because it is established and familiar. My intuition is to avoid the bloated and expensive Salesforce software, even if they have some sort of discount license.

I'm sure that comparisons have been made to Salesforce before but it might be useful to compile some of them in a single place.

# Answer
> 10 votes
Aside from the general arguments against Salesforce, which are well-detailed elsewhere - it's designed for business-to-business interactions. That results in odd architectural decisions. For instance, all individuals must have an organization they're tied to. That often doesn't make sense in the non-profit world, with individual donors, social services clients, etc.

To combat that, a group of folks with the financial backing of the Salesforce Foundation created the Salesforce Non-Profit Starter Pack (NPSP). This is available at no cost, and alleviates a lot of the pain of using Salesforce in the non-profit context.

Unfortunately...in the past year, Salesforce Foundation has decided to create a new package called "NGO Connect", and it's much more expensive. Instead of 10 free user seats, you get 2 - and after that it's $90/user/month. Salesforce Foundation has started to redirect its resources there. As a result, a lot of features that many non-profits consider essential are ending up in the more expensive NGO Connect, and will likely never end up in the NPSP.

Whether this matters to your clients, who sounds like their CRM needs are quite basic, I'm not sure - but this is the primary concern with the non-profit Salesforce ecosystem right now.

EDIT: By request, I'm updating this with more info.

* Here's a comparison of NPSP vs. NGO Connect. I wouldn't expect features developed for NGO Connect to be available for NPSP users, or they'd kill their differentiation. In fairness, NPSP seems to still be under active development.
* The power of Salesforce is in its integrations. However, the integrations are a) additional paid packages, b) are generally priced for enterprise use. You can end up spending a lot to get a strong Salesforce experience.
* The Salesforce real-time API is slow, and you're subject to API limits. Those API limits are dinged every time you use a non-Salesforce native integration.

# Answer
> 6 votes
My experience with Salesforce in particular with website integration is that it falls short and depends too much on 3rd parties to provide the conduit between the website and the Salesforce account.

I've been working with an organization who decided to go big with Salesforce and all the associated costs *"because it is established and familiar"* -- however after contracting two sets of Salesforce experts to integrate Salesforce with their site, it does very little more that collect leads when people download PDFs from their online library. Events aren't integrated, eNewsletters are not integrated and they have no membership or pledge component.

I'm not sure if it is just that they can't find a good Salesforce expert or that Salesforce and Drupal don't like working together but I do know for certain, CiviCRM would remove the Salesforce costs and provide a much fuller, integrated and consolidated solution.

CiviCRM isn't a magic solution that does everything for you. You will need to learn the ropes to make it fly but it is designed to work seamlessly with Drupal, Joomla and Wordpress so there is no trying to force square pegs into round holes and vice-versa. It sounds to me based on what you've written that CiviCRM would be a good fit for your organization.

# Answer
> 3 votes
There is actually an organization who specializes in non-biased comparisons of software for nonprofits. Check out Idealware. Specifically, grab their latest report on donor management systems.

It has Civi, SalesForce's nonprofit offering, Blackbaud, DonorPerfect, and the other major players.

---
Tags: scheduling, logs
---


# Question
Title: Enable location "Name" in CiviEvent location configuration?
Is there a way to enter a location name above the address fields in CiviEvent location settings?

When configuring an event:

It would be nice to be able to place the name just above the address like this:

```
"Conference Center Name"
Street address 1
City, State, ZIP

```

Anybody know how to do this?

# Answer
If you enable the *Address Name* field globally, it will become available on the Event Location screen.

From `Administer CiviCRM → Localization → Address Settings` (or browse directly to /civicrm/admin/setting/preferences/address ), check the box for *Address Name* under the *Address Editing* section.
> 7 votes

---
Tags: civievent
---


# Question
Title: Custom options on CiviEvent registration forms to handle breakout session choices
A common need in event registration systems is the ability to allow participants to select from a list of concurrent "breakout" sessions that will occur in various time slots during the course of the event.

I know this *could* be achieved using custom fields in a profile inserted into the event Online Registration form. I don't like this because (1) it's "clumsy" as Dave Greenberg admits (and the average user will not enjoy the process of creating a custom field group, custom fields/options, and including them in a profile—no way!), and (2) Some of the fields/options will only be used one time and would clutter up the permanent list of custom fields in the system.

Ideas on alternatives are welcome!

# Answer
I've tried a bunch of approaches, and price sets are definitely the best approach here.

* Create a "Select" price set for each group of concurrent sessions (e.g. "Workshop Session 1", "Workshop Session 2", etc.).
* This also allows you to charge different amounts for different sessions, if some incur an additional cost.
* The price set options selected will be stored on the participant record as "Fee Level", and can be easily searched/displayed.
> 2 votes

---
Tags: civievent
---


title: Using contacts as event locations

text:
# Question
Title: Using contacts as event locations
Is there any extension or any other way to use regular contacts as event locations? This has been asked on several occasions in the forum, and the response has been "well, at least you can re-use event locations."

We have a membership organization of local businesses, and a monthly meeting that rotates among the board members' offices. So, being able to look up a member's office and select it as the venue would be far easier than re-entering the data. Moreover, the event location fields are limited— email address but no website?— whereas the contact records have custom fields for things like parking, security, and public transit information associated with the location.

By tying an eveny to a venue rather than a location, I wonder if it might be easier to record hosting an event as an activity for the organization as well.

Since event locations are stored in the `civicrm.address` table already (though they are inaccessible from any other part of the system), I wonder how difficult it would be to refactor events to use contact addresses. But leaving that aside, is there at least a workaround? I suppose we could use a contact reference custom field, but that would require a good deal of customization to display more than the contact name, I would think.

# Answer
> 6 votes
It would require a change to the core function CRM\_Event\_BAO\_Event::getLocationEvent(). Right now, it only pulls addresses that are tied to existing events. Theoretically, the schema supports addresses that are tied to contacts also being tied to events, but there's no way to set the contact ID on an event address or vice-versa.

In one sense, it would be nice to have an extension or core feature that is an address manager for merging addresses. (In civicrm.org, there got to be two locations for the trainings we have at AGH Strategies: one on Colorado Avenue and one on Colorado Ave. NW. There's no way to merge them with each other, let alone with the record for the actual company.) Alternatively, it would be nice to have a third option besides "Create new location" and "Use existing location"--a "use contact's location" option would be basically what you need.

However, it does introduce one potential question: what if the contact moves? If the AGH Strategies office moves to 14th Street, let's say, we'd edit our contact record at civicrm.org and the same address ID would now read 14th St. NW. If those event records were tied to our address rather than a separate one, they'd suddenly say that trainings from last year were held on 14th Street rather than Colorado Avenue. Now, the location of past events isn't usually a concern, but it might be one for some folks, maybe to demonstrate all the places they've had events or to research areas that are underserved. Tying event locations to contacts would, at the very least, introduce this problem.

# Answer
> 4 votes
It would be a simple extension to write, and would likely make a small group of users quite happy.

Just fyi, it's currently possible to add a custom field to addresses, so you could create a contact reference field limited to the contacts who host as a custom address field. It would appear on the event location form if you do. Then you will likely want to write jQuery so that when a contact is selected in that field on the Manage Event Location tab the values in its work address fields get copied into the event location fields. The use of the event location fields would be the same as before. However, you would need to suppress that contact reference field from appearing anywhere else. It's a bit quick and dirty. A more elegant approach would be to use jQuery to insert a contact reference field just into that form, with same copying done on select of a contact.

In case this helps, we have made it so you can use the supplementary address 1 and 2 fields on event location, and have values displayed in the event location option list. In our case this meant that different conference room for monthly lunches in the same hotel could be selected. In yours, you might be able to use those fields to display info like parking instructions, etc.

---
Tags: civievent, addresses, contact-reference
---


# Question
Title: Example of adding multi-record custom fields to a contact via API
When I attach a multi-record custom field group to a profile for contribution pages, Civi only allows visitors to enter the fields once. I've read through jira a bit and see that the capability isn't there currently. Is there a simplified example showing how to use API v3 (preferably PHP, but any method is fine) in a way that adds a multi-record custom field group at the end of a contribution (i.e. after payment processing is complete)?

# Answer
> 1 votes
To clarify this scenario: you must be talking about muti-record *contact* custom data and not *contribution* custom data (which only supports single-records currently).

I recommend you use hook\_civicrm\_postProcess to insert code to store the data on form submission. This code inside your implementation of the hook should use the CustomValue API to save the data. You'll find documentation and examples of how to use it in the API explorer.

---
Tags: api, profile, custom-fields
---


title: How is the restful API secured?

text:
# Question
Title: How is the restful API secured?
In order to access the API securely what do I need to do?

Is it as simple as using `https` and letting my CMS manage session authentication?

# Answer
> 8 votes
Whether or not https is used would be dependent on the CMS, but this is certainly recommended. Other than making sure the Access AJAX Api permission is set up for a particular CMS user, you will also need to pass a user api key that is assigned to the CiviCRM contact record associated with that CMS user.

**Details at:** http://wiki.civicrm.org/confluence/display/CRMDOC/REST+interface#RESTinterface-SettinguptousetheRESTAPI

# Answer
> 8 votes
The REST API requires that you specify the site key and an API key. Details can be found here.

---
Tags: api, security, rest
---


title: How Do You Create Users from Contacts?

text:
# Question
Title: How Do You Create Users from Contacts?
I am currently using a Drupal 7.35 CiviCRM 4.4.14 build for a new website. I have all of contacts set up, with their relationships and memberships, and all the rules in place so that as it changes in Civi it pushed the changes on Drupal.

What I do not understand however, is how to migrate the 1000 or so contacts in Civi to create their log-ins in Drupal.

Some webpages suggest exporting to CSV and importing from CSV; and I have not even started looking into Drush.... surely there must be an easier way?

# Answer
I've done this a few times using the User Import module. You just get a contact listing of all the contacts in CiviCRM that need an account (for example, all of the contacts in a particular group or those that are returned from a particular search) and then do a simple CSV export of the relevant information.

You could export the email address, first name, last name, and then edit the list in a spreadsheet if you need to generate custom usernames or passwords. The module will allow you to construct usernames on the fly by using multiple fields. You can optionally abbreviate them as well, so you could do a username as any of the following without any extra editing of the CSV data:

* FirstLast
* FLast
* FirstL

The module will also allow you to send the welcome email (or a custom welcome email), assign roles, and more.
> 6 votes

# Answer
I've had good results using Drupal rules. The recipe is set in detail here by Pete from Fuzion in NZ - thanks Pete: https://civicrm.org/blog/petednz/creating-drupal-users-made-easy-for-single-or-multiple-contacts-via-civi-imports-and

I guess I would first be sure that you need to create user accounts for all your users all at the same time. Using this recipe, you can manage when accounts get created.
> 4 votes

---
Tags: contacts
---


# Question
Title: How can I reference a contact's Drupal/Wordpress/Joomla account with a CiviMail token?
From time to time we need to send messages through CiviMail that include a contact's CMS (Drupal/Wordpress/Joomla) username or ID. How can we add this to the available tokens?

# Answer
**Option 1: Use the CiviToken extension \[recommended, CMS independent\]**: Fuzion's CiviToken extension provides `{user.name}` and `{user.id}` tokens by default. (*Pro tip:* this module also makes it easy to add custom tokens in a *tokens/* folder in your CiviCRM custom PHP directory; you can duplicate and modify a file from the *tokens/* folder in this extension)

**Option 2: Custom token in your own Drupal module \[Drupal specific\]**: Coleman authored a blog post some years back which outlined how to make custom tokens. The following snippet is based on that and when slipped into a custom module will make the Drupal username available as a token in CiviMail.

```
<?php
/* CiviCRM token addition for Drupal username */

function MYMODULE_civicrm_tokens(&$tokens) {
  $tokens['username'] = array(
    'username.drupal' => 'Drupal username',
  );
}

function MYMODULE_civicrm_tokenValues(&$values, $cids, $job = null, $tokens = array(), $context = null) {
  // Username tokens
  if (!empty($tokens['username'])) {

    civicrm_initialize();
    foreach ($cids as $cid) {
      $params = array(
        'version' => 3,
        'sequential' => 1,
        'contact_id' => $cid,
      );
      $result = civicrm_api('UFMatch', 'get', $params);
      if (!$result['is_error']) {
        $drupalinfo = user_load($result['values'][0]['uf_id']);
        $values[$cid]['username.drupal'] = $drupalinfo->name;
      }
    }

  }
}
?>

```

Keep in mind that this is the bare bones and doesn't include any handling of a contact without a Drupal account. (So you would want to make sure to only use this token when sending to contacts with a Drupal account.)
> 5 votes

---
Tags: civimail, wordpress, drupal, joomla, tokens
---


# Question
Title: How to automatically set PDF 'Activity Subject' from template subject?
Is it possible to automatically set the 'Activity Subject' of PDF letters to the 'Message Subject' of the selected template? I swear I've seen this done with a quick bit of code, but the keywords are escaping me...

# Answer
> 4 votes
Tracked this one down. It worked out of the box in 4.4.x, but doesn't in 4.5.x. Not sure whether it was deliberate, but it's pretty easy to 'fix'.

Edit templates/CRM/Mailing/Form/InsertTokens.tpl and change:

```
  cj.post( dataUrl, {tid: val}, function( data ) {
    if ( !isPDF ) {
      if (prefix == "SMS") {
          text_message = "sms_text_message";
      }
      else {
        cj("#subject").val( data.subject );
      }

```

to:

```
  cj.post( dataUrl, {tid: val}, function( data ) {
    cj("#subject").val( data.subject );
    if ( !isPDF ) {
      if (prefix == "SMS") {
          text_message = "sms_text_message";
      }

```

It's explicitly only setting the Activity Subject for non-PDFs, which is weird. It looks like it was accidentally(?) reverted when SMS support for recurring contributions was being added. Have created an issue.

# Answer
> 1 votes
You may be able to use hook\_civicrm\_pre. But i'm not sure you have the template in this context.

```
function myextension_civicrm_pre( $op, $objectName, $id, &$params ) {
  if ($op == 'create' && $objectName == 'Activity') {
    // define PDFLETTER_ACTIVITY_ID or replace with the good id
    if ($objectRef->
    $params['activity_type_id'] == PDFLETTER_ACTIVITY_ID) {
      // 1. get the template (is it possible from there ?)
      ...

      // 2. replace the title
      $params['subject'] = ...
    }

  }
}

```

Otherwise you will have to use hook\_civicrm\_postProcess but it's more complex.

---
Tags: templates, pdf
---


title: How to update latest.civicrm.org?

text:
# Question
Title: How to update latest.civicrm.org?
There's a file http://latest.civicrm.org/versions.json which isn't up to date - it's missing a few betas, but most notably, it's missing CiviCRM 4.4.14. This is the source data for CiviMonitor, which uses it to check if a version is up-to-date.

Is this file generated by hand, or with code? If by hand, is there a git repo I can submit a PR against?

# Answer
You are correct that latest.civicrm.org/versions.json is the canonical source for CiviCRM version information.

The file is quite new and the release-publishing script has not yet been updated to write to it (an issue has been filed for this), so at the moment it must be updated by hand.

I agree that the file should be under version control.

If anyone is available and interested in helping with either task, get in touch on #civicrm IRC channel, or by email to coleman at civicrm)
> 4 votes

---
Tags: upgrade, documentation, version
---


# Question
Title: How can I tell if the logged in user has a certain permission?
How can I tell if the currently logged-in user has a certain permission in CiviCRM?

Should I use CMS-dependent functions, like user\_access('permission') in Drupal, or can I use one CiviCRM function to check the permission for the current user?

For example, how could I display a message if the currently logged-in user has the 'edit all contacts' permission?

# Answer
> 4 votes
I believe what you're looking for is:

```
CRM_Core_Permission::check('edit all contacts')

```

# Answer
> 1 votes
It depends how you've set the permissions, what ACL groups they're in or what roles you've given them in the CMS

---
Tags: permissions
---


# Question
Title: How do I automatically make roles inactive when case is resolved
CiviCRM Version 4.5.6

Looking at some case types (it seems to work for other case types) where after case status has been changed to "resolved," case roles remain active.

Is there a way to automatically end date these relationships?

# Answer
Well after further testing, it appears that the case roles are end-dating the day the case is resolved.

I'm not sure where our issues were cropping up, but this is a fairly new install with lots of data being imported which is where I suspect the issues arose.

Sorry for the red herring.
> 1 votes

---
Tags: relationships, civicase, roles
---


# Question
Title: How do I allow registration for one day of a multi-day event?
A use-case has come up where there is a need to hold a multi-day event where participants can register for "One day only". So if the event was Wed, Thurs & Fri, they could choose "Friday only" at registration.

I am thinking that Price Sets handles this nicely, although the rest of the event confirmations, reminders, etc. would not acknowledge that they are only attending for one of the days.

Anyone have experience with this or ideas beyond just using price sets?

# Answer
> 4 votes
I have successfully used price sets for exactly that purpose.

You can customise the event confirmation/receipt at **Mailings \> Message Templates \> System Workflow Messages**. These are written using Smarty.

{if $event.id eq 'XX'} will let you selectively customise the receipts for a particular event.

{if $line.label eq 'Friday only'} should let you customise at the individual line item level once you are in the line item loop.

For scheduled reminders you may be able to use Search Builder to create smart groups based on the fee label and so send different reminders depending on the day(s) of attendance using "Limit to - Group ".

# Answer
> 0 votes
I think that including the dates as part of the price set labels would make this approach viable.

The other approach is cart-style event checkout, but that's a far more complicated setup that I don't think is warranted here.

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


title: How do I upload mailing content in 4.6?

text:
# Question
Title: How do I upload mailing content in 4.6?
I love the new Civi mail enhancements in 4.6 but just wondering what happened to the "upload content" button. Is it still possible to upload mailing content from a file?

# Answer
In the HTML rich text editor, there is a button called "Source". You can use this to send custom HTML:

1. In a text editor (e.g. Notepad), open the desired file. Copy all the markup.
2. In the CiviMail UI, click "Source". Paste the markup.
> 6 votes

# Answer
You can also copy and paste content into the editor. I see that there is even a paste from Word button so hopefully most needs can be met.

Luckily with the new, more robust, editor any necessary modifications needed after pasting should be easier to make.
> 2 votes

---
Tags: civimail
---


# Question
Title: How can I allow non-admin users to manage tags?
I have a Drupal role which I have given the permission `CiviCRM: administer Tagsets` and `CiviCRM: administer reserved tags` but not `CiviCRM: administer CiviCRM`.

They still get access denied when visiting `/civicrm/admin/tag?reset=1`.

I do not want to give them `CiviCRM: administer CiviCRM`.

What can I do?

# Answer
> 7 votes
This is a bug already reported at https://issues.civicrm.org/jira/browse/CRM-15371.

Managing tags needs its own permission rather than requiring "administer CiviCRM" permission. Anyone interested in getting started on core programming will likely find this a good one to begin with.

---
Tags: permissions, acl, tags
---


# Question
Title: How to display an extension's form as a public Wordpress page
I'm experimenting with the jQuery Repeater plugin to create multiple contacts via a single form. Using Civix, I've created an extension and a custom form. The form loads normally on the admin side, like:

`http://site.org/wp-admin/admin.php?page=CiviCRM&q=civicrm/foo`

What is the proper way to expose the form to the public site? The goal is to send the visitor to:

```
http://site.org/civicrm/foo

```

Once there, user will fill and submit the form, and the extension's hook will deal with the result. Given the warnings all over the docs about custom forms potentially breaking in future updates, does it even make sense to approach things this way? Or is it better to put the form on a WP page, using REST API calls to populate dropdowns and checkboxes, and deal with the result?

# Answer
1. See also: http://wiki.civicrm.org/confluence/display/CRMDOC/Displaying+Public+Forms+in+WordPress+Frontend+Sites
2. If you generate a link programmatically with `CRM_Utils_System::url()`, there is a boolean parameter ($frontend) which determines whether the URL will use WP's frontend system or backend system. Most forms are in the backend, so the the default is to use backend. See also: https://github.com/civicrm/civicrm-core/blob/4.6.beta5/CRM/Utils/System.php#L212
3. It would be great to support clean URLs (`http://site.org/civicrm/foo`) on WordPress. I'm not a WordPress expert, and I've been told this is an esoteric area in WP (virtual pages?), but from Civi's perspective... we basically need some kind of rule in WP that maps all requests for "/civicrm/\*" to CRM\_Core\_Invoke::invoke().
> 5 votes

# Answer
When you create the form in civix using

```
civix generate:form MyForm civicrm/myform

```

I believe the last parameter determines the WordPress page to have the parameters &page=CiviCRM&q=civicrm/myform&reset=1. If not then you likely need to implement a shortcode for it.

Note that after adding or modifying a route in the XML file, you must reset CiviCRMs "menu cache". This can be done in a web browser by visiting "/civicrm/menu/rebuild?reset=1"

Also beware: The form system is not well documented and may undergo significant revision after the CiviCRM 4.x series. In general, migrating basic pages will be easier than migrating basic forms, so you may want to consider to consider building your data-input UI using basic pages, the AJAX API, and/or the in-place editing API.
> 1 votes

---
Tags: wordpress, extension
---