Opened 19 years ago
Closed 18 years ago
#2541 closed defect (bug) (fixed)
Filter hook for checking registration information
Reported by: | thefreefood | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | minor | Version: | 2.0.1 |
Component: | General | Keywords: | registration register filter hook has-patch 2nd-opinion |
Focuses: | Cc: |
Description
I would like to prevent users from registering to my site if their email address is not from a specific domain. For this purpose and other similar types of restrictions on registration, it would be convenient to add a filter hook to wp_register.php that passes an array with username, password, and email address information and returns an errors array that is incorporated into $errors before the user is registered. Then, if a filter returns NULL, registration would proceed. This seems like it would be broadly useful.
Attachments (1)
Change History (3)
#1
@
19 years ago
- Keywords has-patch 2nd-opinion added
- Milestone changed from 2.0.2 to 2.1
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
Agreed on the usefulness of this.
I whipped up a quick patch. The e-mail is passed through user_registration_email filter. The $errors array is passed through registration_errors filter.
So something like:
function user_emails_on_my_domain($email) { if ( strpos($email, '@mydomain.com') === false ) { // obviously use a better check than this! add_filter('registration_errors', create_function('$errors=array()', '$errors[\'user_email\'] = \'<strong>ERROR</strong>: This email does not end in "@domain.com"\'; return $errors;')); } return $email; } add_filter('user_registration_email', 'user_emails_on_my_domain');
Untested, but you get the idea. Going to have to be a 2.1 milestone.
User Registration Email filter and Error Filter