<< Return to Profiles Admin Main Page

Overview

PROFILES may be linked to specific modules, used to create standalone forms as well as search and listing pages.

Examples of module links include:

Permissions for Profiles (Drupal Only)

For Drupal installations, you can use Drupal Access Control to determine which "roles" can access Profile forms and listings (as well as Contribution and Event Registration pages with contain Profiles):

Since many sites use profiles for constituents who may not have user accounts - this configuration is the most common. However, you can restrict general access to profile pages and forms by assigning these permissions to specific roles.

If you need to limit access to specific profiles for subsets of your user population - you can do so using by using Access Control Lists (ACLs) (learn more...).

If you need to restrict access to a specific profile for anonymous users (for example, a members' only directory) but you still want anonymous users to see other profiles on your site, you can add a function to your Drupal theme to do this.  You might be thinking that simple Drupal modules like Path Access could do this but with clean URLs enabled, you can't use a CiviCRM path because of characters like ? and &.

  1. You must first create a custom "access denied" page with the user login block visible on that path (or if you use the LoginToboggan module, you can set it so the login fields appear on your access denied page).
  2. Then create a URL redirect using the Path Redirect module from something "clean" like <yoursite>/memberdirectory to <yoursite>/civicrm/profile?reset=1&gid=11 (with the ID of the profile you want people to go to).
  3. Then insert the below function into your template.php file. In Drupal 6, it should go in phptemplate_preprocess() and in Drupal 5 in _phptemplate_variables() You will need to change the profile ID, the access denied path (created in step 1 above) and the destination path (created in step 2).
// Anonymous users trying to access the membership directory, need to be redirected
// to the login page with the proper destination set.&nbsp; Since there can be different
// parameters in the URL, we're only checking for civicrm profile and gid=11.
if ($user->uid == 0) {
  // trying to access a profile
  if (arg(0) == "civicrm" && arg(1) == "profile") {
    if (strstr(drupal_get_destination(),'gid%3D11')) {
      header('Location: /members-only?destination=membershipdirectory');
      exit;
    }
  }
}

Once you do this, when people try to access the profile, they will get your access denied page but once they login, will be redirected to the profile you wanted them to go to.  Not elegant but it worked for us. To visit forum post, click here.

If you need to restrict anonymous access to certain forms a safer way to accomplish this would be to implement hook_civicrm_buildForm from within a custom module.  This pulls the access control logic out of Drupal's theme layer.  To do this, follow step 1 as listed above and then add this code to your custom module:

// Anonymous users trying to access a specific form or forms, need to be redirected
// to the login page

function MODULENAME_civicrm_buildForm($formName, &$form) {
  global $user;


  // The form id(s) that you want to restrict anonymous access to can be defined here:
  define ('FORM_ID', 11);


  if ($user->uid == 0) {
    // If we are inside of this IF block, then the user attempting to access a civicrm form is anonymous
    if ($form->_id == FORM_ID) {
      // If we are inside of this IF block, then the civicrm form being accessed is restricted for anonymous users
      drupal_goto('path/to/your/custom/access/denied/page');
    }
  }
}

Linking to Built-in Contact Create/Sign-up Form(s)

Refer to your Drupal or Joomla documentation for information on creating links and menu items.

* Make sure your profile has and includes at least first name and last name OR email address, as these are the minimum required fields for creating a new contact.

Linking to Built-in Contact View and Edit Page(s)

Refer to your Drupal or Joomla documentation for information on creating links and menu items.

You can also use a Profile to give logged-in users a way to view and/or edit specific fields from their own contact data.

As with any profile, you control the fields you want exposed to these view and "self-service edit forms" by the fields you select to include in the profile.

Give your logged in users a custom edit form by linking to <site root>/civicrm/profile/edit?reset=1&gid=N where N is the ID of the Profile. (Each Profile has a unique numeric ID - you can find the value by checking the second column of the table at CiviCRM » Administer » CiviCRM Profile).
Any information that exists in the contact record for the included profile fields will be retrieved and displayed in the form.

Give your logged in users a customized view of their contact info by linking to <site root>/civicrm/profile/view?reset=1&gid=N where N is the ID of the Profile. Any information that exists in the contact record for the included profile fields will be retrieved and displayed.

A great feature is to "invite" your non-logged in users the ability to view and edit their contact info via a profile using CiviMail. To do this, insert the following link with appropriate tokens as shown into a CiviMail message:
http://<site root>/civicrm/profile/edit?reset=1&gid=N&id={contact.contact_id}&{contact.checksum}
... where N is the ID of the Profile you want them to use for editing. The contact checksum token generates a special link that gives a user access to edit their information in that profile for 7 days from the day you send them the mailing.

Profile Search and Listing

To allow searching and listing of profiles:

Link to <site root>/civicrm/profile?reset=1&gid=N (where N is the Profile ID) to display a Search and Listings page which provides basic search on any "Public and User Listings" Profile fields - and returns a sortable listing of contacts.
For example: the link to display a search and listings page for a Profile with ID = 3 would be <site root>/civicrm/profile?reset=1&gid=3

If you are using profiles to list members of a group - you can have the group members appear automatically when the profile page is loaded by using the force parameter. You can also hide the Search form by adding &search=0.
To immediately a listing for Profile ID 3 without a search form:

http://..../civicrm/profile?gid=3&reset=1&force=1&search=0

You can also create external links to specific Listings filters by creating the url q=civicrm/profile?reset=1&force=1&gid=N&field_name=value.

To specify the amount of rows in a page list, you can add "crmRowCount" parameter to url, like q=civicrm/profile?reset=1&force=1&gid=N&crmRowCount=9 .

Be sure to verify the correct field names and values to use in these these URLs by checking the field link from a My Account page, OR by browsing to your profile's listing page without additional filters and doing View Source from your browser.

Mapping a Group of Contacts using a Profile

Showing a map is also possible:

  1. Create the profile. Limit listings to a group if needed. Let's assume profile id is PID.
  2. Make sure you have mapping enabled for this profile (this is a checkbox in the profile's Advanced Settings)
  3. The url to map all contacts from that profile is: civicrm/profile/map?reset=1&gid=PID&force=1&map=1

    Each Profile has, under Settings (Advanced Settings section) the option to Limit Listings to Group.  If you are reading this looking to figure out how to format a complex query string, like I was trying to do, Senators & Delegates or something, or not null in some field, do yourself a favor and create a Group, then use Limit Listings to Group to control which contacts are available in the profile search.

Contact Creation or Sign-up Forms using Profile HTML Form Snippet

If you want to place standalone contact create / sign-up form(s) anywhere on a web-site (outside of CiviCRM pages) navigate to Customize » CiviCRM Profile, and then click more and then HTML Form Snippet.

Customized Advanced Search Results

To display a different set of columns from the defaults in Advanced Search results: