wwwolf on "Restrict user registration to emails on a single domain"

ساخت وبلاگ

I need to allow user registrations only for those with email addresses on a single domain. I have tested multiple regular expressions and this one works well in a regex sandbox environment, but as soon as I put it into my functions.php file, it simply rejects all registrations - even email addresses on the correct domain (with the error message below, so it's definitely this conditional that's breaking it). Am I:
a) actually doing something stupid in the regex, even tho the online regex testers say it's doing what I want?
b) using a regex syntax that WordPress doesn't support?
c) screwing up something in the rest of the function?
d) misunderstanding the codex, and it's not as simple as just adding this to functions.php?

add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 ); function myplugin_registration_errors( $errors, $sanitized_user_login, $user_email ) { if (!preg_match('( |^)[^ ][email protected]( |$)', $user_email )) { $errors->add( 'invalid_email', __( 'ERROR: Only valid "mydomain" email address is allowed.' )); $user_email = ''; } return $errors; }

I've been staring at this so long now, it could be blindingly obvious and I wouldn't see it!

Many thanks!

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 385 تاريخ : پنجشنبه 21 مرداد 1395 ساعت: 15:52