Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

q2a-open-login: Allow google login for specific domain's emails

0 votes
asked Nov 20, 2014 in Plugins by rony36

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
answered Nov 20, 2014 by Ami
edited Nov 24, 2014 by Ami
Best answer

Check this function which validates the email address .


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


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


commented Nov 24, 2014 by rony36
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?
commented Nov 24, 2014 by Ami
I have updated the answer . Please check