How can we disable FB login based on some condition. For example if the time is between 2am and 4am disable the facebook login ( just an example) . My problem is not with the logic of the condition, I can certainly apply that. but my problem is once the condition is met then how to disable the fb login programmatically in hybridauth
Thank you in advance
Ps. you may wanna look into the code here:https://github.com/hybridauth/hybridauth
From the documentation we can see this entry;
enabled
can betrue
orfalse
; if you don't want to use a specific provider then set it tofalse
If you open hybridauth/config.php
, you'll see a configuration array, which holds configurations for different authentication methods. Most interestingly, we can see an key named enabled
, which we can manipulate.
We can modify the value directly, by using the ternary operator. For example;
...
"Facebook" => array (
"enabled" => (condition ? true : false), //Ternary operator modifying `enabled` value.
"keys" => array ( "id" => "", "secret" => "" ),
"trustForwarded" => false
),
....
However, we can do this by modifying it after the configuration has been loaded.
If you open up examples/social_hub/login.php
, you'll see we load the config file and use it. Here is where we can modify that enabled
key.
The configuration is held within the variable $config
, so;
if( condition ) {
$config['providers']['Facebook']['enabled'] = FALSE;
}