Hi

Is it possible to only let users with an email address from a certain organisation, eg. a university, register in drupal 6.

I tried to use the "pre-approved" module in connection with "verify email" module.

Any help?

Comments

mshepherd’s picture

Hi,
You don't need contrib modules to do this. It's built into core.

Read about access rules
http://drupal.org/getting-started/6/admin/user/rules

The Drupal 5 version of this page describes the rules slightly better:
http://drupal.org/node/107557

nilsja’s picture

i understood how to allow %@mydomain.net. But how do deny %@allotherdomains.com?

Thanks,

Nils

mshepherd’s picture

As in the example on http://drupal.org/node/107557, you can 1st create a rule to deny all email addresses:

* Deny %@% (which blocks all e-mail address)

Then another rule to allow email from particular domain:

* Allow %@institution.edu (which will allow people with anyone@institution.edu)

vaene’s picture

I've searched around quite a bit including the hacks on register pre approved module, but I can't see how to allow users from a certain domain, say @cooldomain.com to register without approval and then have others have to be approved by admin. Seems like a not so loopy feature to want in a website? Anyone been able to pull this one off?

Stomper’s picture

I think in one of the site configuration menus you set it to require or not require approval. Perhaps you could create a rule using the rules module so that if the domain matches it does not need admin approval.

stephenrobinson’s picture

Just use the webform module, add some custom php to the _validate textarea to check for a substring match of your domain from your email form field, and add a form set error to prevent submission.

bradweikel’s picture

Since people are sure to ask this question about Drupal 7...

Access Rules has been removed from Core in D7. It looks like it will (eventually) be provided in the User Restrictions contrib module:
http://drupal.org/project/user_restrictions

mshepherd’s picture

Thanks for the heads up. Good to know.

jdleonard’s picture

Stomper’s picture

Will setting the allow to "%.edu" work - meaning it checks for ".edu" not necessarily "@something.edu"?

Thanks

wolf_22’s picture

Will, it seemed to work for since I locked myself out! Talk about taking one for the team...

Hehe. Simple phpMyAdmin fixed that, but yes, it seems to work flawlessly. :.)

Stomper’s picture

Glad to know the technique works. I'll try it soon.

In the event I lock myself out, could you please detail the PHPMyAdmin steps needed to get back in?

Cheers.

Stomper’s picture

Wolf22, in the case I do what you did and lock myself out, could you tell what PHPMyAdmin steps you took to regain access.

Also, I am assuming that if you make access rules, it is impossible to deny access/lock out the site admin (user 1), correct?

wolf_22’s picture

Stomper, I'm sorry I didn't reply sooner. I don't normally float around here that often due to work and school, but basically I found my user record in the main user table and simply changed my e-mail address. When I was back in, I was able to change everything henceforth through the normal backend.

Stomper’s picture

No worries, I ended up locking myself out (user 1) but was able to delete the rules from the DB using PHPmyAdmin. Not difficult at all.

I just wonder why Drupal would allow rules that would lock out the admin/user 1. Seems a little odd. For someone administering a Drupal website and not knowing what to do, being locked out as the admin can be stressful.

mlncn’s picture

http://drupal.org/project/useremaildomain

User Email Domain is easier to use because it is simpler than User Restrictions

benjamin, Agaric