I know that's development version, but maybe following issues can be useful:

Followed existing code during inserting the user checking only first part of the path (arg(0)):

function autoassignrole_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'insert':
      $page = db_fetch_object(db_query("SELECT rid FROM {autoassignrole_page} WHERE path = '%s'", arg(0)));
...
      $edit['roles'] = NULL;
    break;

And at the end, even if some role has been assigned, it's deleted anyway (NULL).
I.E. when I have set path to 'user/register', it's checking only 'user' path, so query return empty array.

The right code should be like this:

      $path = substr(request_uri(),1);
      $page = db_fetch_object(db_query("SELECT rid FROM {autoassignrole_page} WHERE path = '%s'", $path));
...
      //$edit['roles'] = NULL; // delete this line

Comments

cyberswat’s picture

Could you begin by stating what your problem is? You are not allowed to set paths to user/register* or user/password* and should have gotten a validation error when you try to enter either of those as a path.

cyberswat’s picture

Assigned: Unassigned » cyberswat
cyberswat’s picture

Status: Active » Postponed (maintainer needs more info)

http://drupal.org/cvs?commit=146157 applies the path issue you identified ... let me know if there is something else that needs to be looked at

kenorb’s picture

Thank you.
But there is no any validation for 'user/register' path. Anyway it's working, when you changing something (i.e. title or link), but I haven't tested if role assignment is working.

kenorb’s picture

The main point is I can't module make it working using paths as I want.
The next problem is explained here: http://drupal.org/node/320597

kenorb’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Issue fixed.

kenorb’s picture

Status: Closed (fixed) » Needs review

There should be small fix from:

$path = substr(request_uri(),1);

to:

$path = drupal_get_path_alias($_GET['q']);

Because in the first example, when you have additional variables (like /some/page?custom=variable) or you are not using clean URLs, path is wrong received. The same method is used in block.module
The same in autoassignrole_form_alter().

wim leers’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Yep, kenorb's change is necessary to get this to work. Path-based role assignment finally started working after I came to the same conclusion as kenorb.

Also: this module is a prime example of the necessity of unit tests. It's too hard to test everything by hand, and unit tests overcome that problem.

cyberswat’s picture

Status: Reviewed & tested by the community » Fixed
wim leers’s picture

Great, thanks cyberswat :)

Unfortunately I'm prevented from doing any Drupal work the next few months. So I'll have to leave writing SimpleTests to others. Good luck with that though! :)

Status: Fixed » Closed (fixed)

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