When a user is set up to be created at "/user/register" and administrator does not have the ability to create a user at "admin/people/p2rp-create/user" as one would expect.

This is from this code:


/**
 * Implements hook_menu().
 */
function profile2_regpath_menu() {
  $items = array();

  $reg_paths = profile2_regpath_get_reg_paths();
  if ($reg_paths) {
    // Set menu items for each registration path.
    foreach ($reg_paths as $key => $value) {
      $path = $value->path;
      // We will use hook_menu_alter() to deal with the 'user' path later.
      if ($path != 'user') {
        $profile_types = profile2_regpath_get_profiles($path);
        $registration_path = $path . '/register';

        $items[$registration_path] = array(
          'title' => 'Create new account',
          'page callback' => '_profile2_regpath_user_register',
          'page arguments' => array(
            'profiles' => $profile_types,
          ),
          'access callback' => 'user_is_anonymous',
          'file' => 'registration_form.inc',
          'type' => MENU_LOCAL_TASK,
        );
        // Add profile-specific administrative 'add user' page.
        $items['admin/people/p2rp-create/' . $path] = array(
          'title' => 'Add user (' . $profile_types[0]->label . ' profile)',
          'page callback' => '_profile2_regpath_user_register',
          'page arguments' => array(
            'profiles' => $profile_types,
          ),
          'access arguments' => array('administer users'),
          'type' => MENU_LOCAL_ACTION,
          'file' => 'registration_form.inc',
        );
        $items[$path] = array(
          'title' => 'Log in',
          'page callback' => '_profile2_regpath_user_login',
          'page arguments' => array(
            'profiles' => $profile_types,
          ),
          '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(
            'profiles' => $profile_types,
          ),
          '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(
            'profiles' => $profile_types,
          ),
          'access callback' => 'user_is_anonymous',
          'file' => 'registration_form.inc',
        );
      }
    }
  }
  return $items;
}

By pulling out the menu item entry for "user" and putting it above the "if not user" statement all is fixed... like so:


/**
 * Implements hook_menu().
 */
function profile2_regpath_menu() {
  $items = array();

  $reg_paths = profile2_regpath_get_reg_paths();
  if ($reg_paths) {
    // Set menu items for each registration path.
    foreach ($reg_paths as $key => $value) {
      $path = $value->path;
	  
        $profile_types = profile2_regpath_get_profiles($path);
        $registration_path = $path . '/register';
		
		// Add profile-specific administrative 'add user' page.
		$items['admin/people/p2rp-create/' . $path] = array(
		  'title' => 'Add user (' . $profile_types[0]->label . ' profile)',
		  'page callback' => '_profile2_regpath_user_register',
		  'page arguments' => array(
			'profiles' => $profile_types,
		  ),
		  'access arguments' => array('administer users'),
		  'type' => MENU_LOCAL_ACTION,
		  'file' => 'registration_form.inc',
		);
		
      // We will use hook_menu_alter() to deal with the 'user' path later.
      if ($path != 'user') {

        $items[$registration_path] = array(
          'title' => 'Create new account',
          'page callback' => '_profile2_regpath_user_register',
          'page arguments' => array(
            'profiles' => $profile_types,
          ),
          'access callback' => 'user_is_anonymous',
          'file' => 'registration_form.inc',
          'type' => MENU_LOCAL_TASK,
        );
        $items[$path] = array(
          'title' => 'Log in',
          'page callback' => '_profile2_regpath_user_login',
          'page arguments' => array(
            'profiles' => $profile_types,
          ),
          '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(
            'profiles' => $profile_types,
          ),
          '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(
            'profiles' => $profile_types,
          ),
          'access callback' => 'user_is_anonymous',
          'file' => 'registration_form.inc',
        );
      }
    }
  }
  return $items;
}

Comments

grasmash’s picture

Status: Active » Fixed

Thanks. This change has been made to the development versions.

tcalin’s picture

I am not very sure if we are talking about the same thing but I have some issues with adding users by the administrator.
I created two user profiles with registered paths.

Now the symptoms are the following:
- admin/people/p2rp-create/user and admin/people are pointing to the same page
- I have three links Add User (path: admin/people/create), Add user (Basic Membership profile) (path: admin/people/p2rp-create/basic-membership) and Add user (Gold Membership profile) (path: admin/people/p2rp-create/gold-membership)
- if as admin I try to add an user through admin/people/create nothing happens after submitting the form

grasmash’s picture

Status: Fixed » Active
grasmash’s picture

Status: Active » Fixed

The bug fixed in #1689664: User role is not getting automatically assigned when a new user is created by non administrative roles should take care of this issue. please re-open if problem persists.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

had duplicate sentence, typo