You are here

function profile2_install in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.install \profile2_install()

Implements hook_install().

File

./profile2.install, line 11
Install, update and uninstall functions for the profile module.

Code

function profile2_install() {

  // Add an initial profile type, but only if installed manually. In case the
  // module is installed via an installation profile, skip that.
  if (!drupal_installation_attempted()) {
    $type = entity_create('profile2_type', array(
      'type' => 'main',
      'label' => t('Main profile'),
      'weight' => 0,
      'data' => array(
        'registration' => TRUE,
      ),
    ));
    $type
      ->save();
    user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
      'edit own main profile',
      'view own main profile',
    ));
    drupal_set_message(t('A main profile type has been created and assigned to all users. Go to the <a href="!url">Profile types</a> page to add some fields or to configure further profile types.', array(
      '!url' => url('admin/structure/profiles'),
    )));
  }
}