You are here

function profile2_field_extra_fields in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.module \profile2_field_extra_fields()

Implements hook_field_extra_fields().

We need to add pseudo fields for profile types to allow for weight settings when viewing a user or filling in the profile types while registrating.

File

./profile2.module, line 1142
Support for configurable user profiles.

Code

function profile2_field_extra_fields() {
  $extra = array();
  foreach (profile2_get_types() as $type_name => $type) {

    // Appears on: admin/config/people/accounts/display
    if (!empty($type->userView)) {
      $extra['user']['user']['display']['profile_' . $type_name] = array(
        'label' => t('Profile: @profile', array(
          '@profile' => $type->label,
        )),
        'weight' => $type->weight,
      );
    }

    // Appears on: admin/config/people/accounts/fields
    if (!empty($type->data['registration'])) {
      $extra['user']['user']['form']['profile_' . $type_name] = array(
        'label' => t('Profile: @profile', array(
          '@profile' => $type->label,
        )),
        'description' => t('Appears during registration only.'),
        'weight' => $type->weight,
      );
    }
  }
  return $extra;
}