/** * Checks if a user logged in with a given SSO provider. * * @param object $sso_provider. (default: hma_get_logged_in_sso_provider()) * @return bool */ function hma_is_logged_in_with_sso_provider($sso_provider = null) { if ($sso_provider) { return $sso_provider == hma_get_logged_in_sso_provider(); } else { return (bool) hma_get_logged_in_sso_provider(); } }
/** * Log the user out * * @return null */ function hma_logout() { if (isset($_GET['action']) && $_GET['action'] == 'logout') { // logout of a sso provider if (hma_is_logged_in_with_sso_provider()) { $sso_provider = hma_get_logged_in_sso_provider(); } // Fire the WordPress logout wp_logout(); if (!empty($_GET['redirect_to'])) { $redirect = $_GET['redirect_to']; } else { $redirect = remove_query_arg('action', wp_get_referer()); // Redirect to homepage if logged out from wp-admin if (strpos($redirect, '/wp-admin')) { $redirect = get_bloginfo('url'); } } if (isset($sso_provider)) { $sso_provider->logout($redirect); } wp_redirect($redirect); exit; } }