You are here

function profile2_regpath_menu in Profile2 Registration Path 7

Same name and namespace in other branches
  1. 7.2 profile2_regpath.module \profile2_regpath_menu()

Implements hook_menu().

File

./profile2_regpath.module, line 14
Attach profile2 form to registration form according to path.

Code

function profile2_regpath_menu() {
  $items = array();
  $reg_paths = profile2_regpath_regpath_load_all();
  if ($reg_paths) {

    // Set menu items for each registration path.
    foreach ($reg_paths as $reg_path) {
      $path = $reg_path->path;

      // Add profile-specific administrative 'add user' page.
      $items['admin/people/p2rp-create/' . $path] = array(
        'title' => 'Add user (' . profile2_regpath_get_profile_label($reg_path->profile_type) . ' profile)',
        'page callback' => '_profile2_regpath_user_register',
        'page arguments' => array(
          'regpath' => $reg_path,
        ),
        'access arguments' => array(
          'administer users',
        ),
        'type' => MENU_LOCAL_ACTION,
        'file' => 'registration_form.inc',
      );

      // Create registration pages for each profile type.
      // We will use hook_menu_alter() to deal with the 'user/' path later.
      if ($path != 'user') {
        $registration_path = $path . '/register';
        $items[$registration_path] = array(
          'title' => 'Create new account',
          'page callback' => '_profile2_regpath_user_register',
          'page arguments' => array(
            'regpath' => $reg_path,
          ),
          'access callback' => 'user_register_access',
          'file' => 'registration_form.inc',
          'type' => MENU_LOCAL_TASK,
        );
        $items[$path] = array(
          'title' => 'Log in',
          'page callback' => '_profile2_regpath_user_login',
          'page arguments' => array(
            'regpath' => $reg_path,
          ),
          'access callback' => 'user_is_anonymous',
          'file' => 'registration_form.inc',
          'menu_name' => 'user-menu',
          'type' => MENU_CALLBACK,
        );
        $items[$path . '/login'] = array(
          'title' => 'Log in',
          'page callback' => '_profile2_regpath_user_login',
          'page arguments' => array(
            'regpath' => $reg_path,
          ),
          'access callback' => 'user_is_anonymous',
          'file' => 'registration_form.inc',
          'type' => MENU_DEFAULT_LOCAL_TASK,
        );
        $items[$path . '/password'] = array(
          'title' => 'Request new password',
          'type' => MENU_LOCAL_TASK,
          'page callback' => '_profile2_regpath_user_password',
          'page arguments' => array(
            'regpath' => $reg_path,
          ),
          'access callback' => 'user_is_anonymous',
          'file' => 'registration_form.inc',
        );
      }
    }
  }
  return $items;
}