Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
2.5k views
in Plugins by

Say, my domain name is example.com. And I'm using Google Apps for Work. So, I'm having all google services with my email address like: abc@example.com. That means abc@example.com is now working like gmail account..

I've installed this question2answer and using q2a-open-login plugin to register user using Google login. And want to allow the users having email address like xxx@example.com. I want to restrict other domain specific email address to register/login.

How to achive that? Please help.

Q2A version: 1.6.3

1 Answer

+3 votes
by
edited by
 
Best answer

Check this function which validates the email address .

https://github.com/q2a/question2answer/blob/master/qa-include/plugins/qa-filter-basic.php#L34

Here you can make lil bit changes which check the email should ends with your domain name .

_______UPDATE___________

for openlogin add the validation lines before this - https://github.com/alixandru/q2a-open-login/blob/master/qa-open-overrides.php#L134

 // For redirect

qa_redirect('' , array('state' => ($login_error ? 'login-error' : 'login-succ')));
 
// then after rediret to show the error message 
 
$state = qa_get_state();
 
if ($state == 'login-error')
$pageerror = "Login Unsuccessful . Please check your email address .. Blah blah ";
 
$qa_content['error'] = @$pageerror;
 


Hope this helps

Amiya

by
Thanks Amiya, but it's only filtering when user gets manually registered not when authenticating through Google Login! :(
by
in open login plugin here it creates a user .

https://github.com/alixandru/q2a-open-login/blob/master/qa-open-overrides.php#L134

Add your validatations before that .

I will update the answer as well .
by
Great!!! it worked. Thank you so much! could you please help little more? how could I redirect that not-allowed user to home page along with a error message. Is there any predefined function in q2a?
by
I have updated the answer . Please check
...