function profile2_regpath_form_alter in Profile2 Registration Path 7
Same name and namespace in other branches
- 7.2 profile2_regpath.module \profile2_regpath_form_alter()
Implements hook_form_alter().
File
- ./
profile2_regpath.module, line 138 - Attach profile2 form to registration form according to path.
Code
function profile2_regpath_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'user_register_form') {
module_load_include('inc', 'profile2_regpath');
// Logintoboggan might display user_register_form on 403 pages.
if (module_exists('logintoboggan') && variable_get('site_403') == 'toboggan/denied' && strpos(drupal_get_http_header('Status'), '403') === 0) {
$profile_types = profile2_regpath_get_profiles('user');
}
else {
// Get profile2 profile types from current path.
$url = drupal_parse_url($form['#action']);
$path = ltrim($url['path'], '/');
// Check to see if this is an alias. If so, use source path.
if ($source = drupal_lookup_path('source', $path)) {
$path = $source;
}
// Grab first part of URL.
$path_parts = explode('/', $path);
$path_key = reset($path_parts);
// Load profiles for this path key and attach associated fields.
$profile_types = profile2_regpath_regpath_load_multiple(array(
'path' => $path_key,
'status' => 1,
));
}
profile2_regpath_attach_profile_fields($form, $form_state, $form_id, $profile_types);
}
}