Is there an option to set a permission for each registration path?
Ex. Role Admin can register new users with roles Teacher and Student, role Teacher can only register a user with role Student.
Student can't register a user.

Comments

grasmash’s picture

Priority: Major » Normal

Profile2 Registration path creates 2 basic types of forms:
1) An extension of the basic user_registration_form, which is accessible only to anonymous users.
2) An extension of the administration 'add user' form located at admin/people/create.

I could create a set of permissions for accessing the later form type. Is that what you're after?

alesr’s picture

I have point 2 in mind.
Yes,, that's it. Setting a permission for each registration URL, so one role can create one type of user and the other role can create a different type of user with different fields set in Profile types.

grasmash’s picture

Alright, I'll try to add this feature in the near future.

j4’s picture

I am also interested in this feature. Thank you for your module!

Jaya

grasmash’s picture

Status: Active » Postponed

Hm, the more I think about this, the more that it seems outside the scope of this module. You're not really asking for profile related permissions, you're asking for role related permissions. A user of role A needs to be able to create a user of role B.

For D6, a module like administer users by role would have done the trick. I'd be happy to integrate with something like that.

So, I don't think this is appropriate for a P2RP release. However, accomplishing this would take a fairly simple modification.

Just define new permissions per profile type:

/**
 * Implements hook_permission().
 */
function profile2_regpath_permission() {
  $permissions = array(
    'administer profile2_regpath' => array(
      'title' => t('Administer Profile2 registration paths'),
      'description' => t('Enable and configure unique registration paths per Profile2 profile type.'),
    ),
  );

  // Create permission for each profile type's administrative add user page.
  if ($reg_paths = profile2_regpath_get_reg_paths()) {
    foreach ($reg_paths as $key => $value) {
      if ($value->path != 'user' && $profile_types = profile2_regpath_get_profiles($path)) {
        $permissions = array(
          'add user: ' . $profile_types[0]->type . ' profile' => array(
            'title' => t('Create users :label', array(':label', $profile_types[0]->label)),
            'description' => t('Add users with attached profile of type :label.', array(':label', $profile_types[0]->label)),
          ),
        );
      }
    }
  }

  return $permissions;
}

Then you'd need to make a custom access callback for the administrative 'add user' paths. E.g.,

        // 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 callback' => CUSTOM_CALLBACK
          'access arguments' => array($profile_types[0]->type),
          'type' => MENU_LOCAL_ACTION,
          'file' => 'registration_form.inc',
        );

The CUSTOM_CALLBACK would just have to look to see if either user_access('add user: ' . $profile_types[0]->type . ' profile') or user_access('administer users') were true.

I'm postponing for now, but leaving the issue open for discussion.

j4’s picture

Hi,

For anybody arriving here, the module at this node works, http://drupal.org/node/908424, waiting for a proper D7 release though. Thanks madmatter!

Jaya

grasmash’s picture

Status: Postponed » Closed (works as designed)

Closing issue given j4's alternative.

Ilikejava’s picture

On your comment #1: If only anonymous users can register as a P2 profile user, that means that an Authenticated user can't register without logging out? A new user that registers with a P2 profile registration form becomes Authenticated, right? So why not be able to do it both ways? I would like to be able for that to work.

Great module. Thanks.

shortspoken’s picture

Issue summary: View changes
Related issues: +#1481060: Access denied

Hey @Ilikejava,

did you ever find a solution for your suggestion? I am also interested in that functionality so that a authenticated user can get to the registration form and register another account. Would be nice if you shared it here.

Thanks and cheers,
Moritz