function hook_oauth2_login_enabled in OAuth2 Login 7
Same name and namespace in other branches
- 8 oauth2_login.api.php \hook_oauth2_login_enabled()
- 7.2 oauth2_login.api.php \hook_oauth2_login_enabled()
Implements hook_oauth2_login_enabled().
This hook is called when the configuration on admin/config/people/oauth2_login is saved. It gives a chance to the other modules to change their configuration depending on whether oauth2 login is enabled or disabled. The example below enables/disables the menu link for user/login and user/oauth2_login.
1 invocation of hook_oauth2_login_enabled()
- oauth2_login_call_hook_enabled in ./
oauth2_login.admin.inc - Call hook_oauth2_login_enabled() for all modules.
File
- ./
oauth2_login.api.php, line 42 - The programing interface provided by the module oauth2_login.
Code
function hook_oauth2_login_enabled($enabled) {
// Enable or disable the link 'user/login'.
db_update('menu_links')
->fields([
'hidden' => $enabled ? 1 : 0,
])
->condition('menu_name', 'user-menu')
->condition('link_path', 'user/login')
->condition('router_path', 'user/login')
->condition('plid', 0)
->condition('module', 'menu')
->execute();
// Disable or enable the link 'user/oauth2_login'.
db_update('menu_links')
->fields([
'hidden' => $enabled ? 0 : 1,
])
->condition('menu_name', 'user-menu')
->condition('link_path', 'user/oauth2_login')
->condition('router_path', 'user/oauth2_login')
->condition('plid', 0)
->condition('module', 'system')
->execute();
// Clear the cache and rebuild the menu.
menu_cache_clear('user-menu');
}