alixandru / q2a-open-login

Question2Answer Open Login plugin
62 stars 44 forks source link

This is not an issue just a question #49

Closed amint closed 9 years ago

amint commented 9 years ago

I did not know where to ask this, so i posted my question here. My apologies in advance. The question I would like to disable fb loogin based on some condition. For example if the IP address of the user was 45.170.135.24 disable FB login otherwise leave it enabled. ( I already know how to read the IP etc, so checking if the condition is met is not an issue, disabling fb login in my code is whati dont know) I am doing this because in some countries the fb is blocked an if i dont disable the fb login completely the entire website will be blocked. However if i disable the fb login from admin then visitors from other countries can not take advantage of fb login. I looked into the php source but couldn't find out where I should modify the code.

Thank you in advance

alixandru commented 9 years ago

The plugin keeps a list of enabled providers (in an external file, apart from the database) and initializes itself based off this list. The easiest and safest way to achieve what you want is to skip initialization for Facebook provider if the IP condition is met.

You can do it here: https://github.com/alixandru/q2a-open-login/blob/master/qa-plugin.php#L68 Move the function call qa_register_plugin_module(...) inside an if statement like so:

if($provider != 'Facebook' || !isIPAddressBlocked($ip)) { 
    qa_register_plugin_module(...) 
}
amint commented 9 years ago

@alixandru Thank you so much. It did the trick