Closed (won't fix)
Project:
Auto Assign Role
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
14 Oct 2008 at 14:26 UTC
Updated:
24 Jan 2011 at 01:23 UTC
Jump to comment: Most recent file
I've rewrote following permission functions:
function _autoassignrole_path_access($rid = NULL) {
$roles = user_roles(TRUE); // receive all roles
return array_key_exists($rid, $roles) ? user_access("access {$roles[$rid]} registration") : TRUE;
}
/**
* Implementation of hook_perm().
* @return array
*/
function autoassignrole_perm() {
$perm = array('administer autoassignrole');
$result = db_query("SELECT rid FROM {autoassignrole_page}"); // get all used roles by autoassignrole
if ($result) {
while ($db_role = db_fetch_object($result)) { // get db records...
$db_roles[$db_role->rid] = $db_role->rid; // ...and save them to the array
}
$roles = user_roles(TRUE); // receive all roles
foreach ($db_roles as $role) { // for each used role...
if (array_key_exists($role,$roles)) { // .. check if role exist...
$perm[] = "access {$roles[$role]} registration"; // ...and add the new permission
}
}
}
return $perm;
}
Then you will see on Permission page additional access separately for each enabled registration form.
So you can disable creation user's link on anonymous page and enable it for specified role.
It's a good solution, but it will make a little more complicated module with the permissions.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | autoassignrole.module.patch | 3.64 KB | kenorb |
Comments
Comment #1
kenorb commentedI've forgotten. And you need to add 'access arguments' item for main menu item:
And for tabs as well:
After this patch clear cache is needed to do it working (admin/settings/performance).
Comment #2
cyberswat commentedComment #3
cyberswat commentedPlease generate this (and all of your code submissions) as a standard patch http://drupal.org/patch/create
Comment #4
kenorb commentedComment #5
kenorb commentedBut I think it no point to commit that, because you can always have possibility to separate your menus to different blocks and then you can set role permission to specified blocks.
http://drupal.org/node/227418
But this patch can be useful for some people which they can't separate their menu easly, so they can make access by specified form.
Comment #6
cyberswat commentedClosing this out due to lack of movement.
Comment #7
perarnet commentedHello,
I am in the same situation as described above.
Roles:
role_1
role_2
role_3
administrator
Assign from path:
user/register/role_1
user/register/role_2
user/register/role_3
As it works now, paths work fine for anonymous users. But I also want the
administrator role to be able to use the user/register/role_x to create new
users. I think the solution above with permission control is a great way to
solve this issue.
Comment #8
kenorb commentedperarnet:
You can try to make some patch, because I've got AAR so much patched, so it will be difficult for me to patch it for the latest version.
Comment #9
cyberswat commentedI don't think administrators should be able to create users in this fashion.
Comment #10
JayKayAu commentedHi cyberswat,
Would you be able to explain why you don't think admins should be able to create users?
I'm trying to find a solution to a problem where "Staff" users are able to sign up "Customer" users based on supplied information. This is for a physical store where staff are literally speaking face-to-face with customers at the checkout while using a computer with the website open on it.
I would normally just create an ordinary CCK Content Type to store the customer data, except we want to allow these customers to log into the site as well in future.
Is there an alternate solution that you might suggest if it's genuinely not a good idea to do this through autoassignrole?
Comment #11
remaye commentedI suscribe.
I'm desperately looking for a solution (with AAR or any other module) to allow users with Administrator role to create new accounts for new users assigning specific role to them.
Administrator users can create accounts if "access user profiles" and "administer users" permissions are enabled for that role, but are not allowed to choose role for this accounts, why ? And why is this so hard to achieve ?
I really don't understand why "administrators shouldn't be able to create users in this fashion"...
unless there is indeed any other way to achieve this in a more appropriate manner ?
Thanks for any clue...