user_email; if ($portalURL != '' && $sso_password != '') { try { $url = "https://appapi.gotomyaccounts.com/v1/SSO/?email=" . urlencode($email) . "&portal_hostname=" . urlencode($portalURL); $args = array( 'method' => 'GET', 'timeout' => 60, 'sslverify' => false, 'headers' => array( "Authorization" => $sso_password ), 'body' => array(), 'cookies' => false ); $response = wp_safe_remote_get($url, $args); if (!is_wp_error($response)) { $result = $response['response']; if ($result['code'] == 200 && $result['message'] == 'OK') { $token = $response['body']; } else { $token = ''; } } else { $token = ''; } } catch (Exception $exc) { $token = ''; } } return $token; } function gtma_redirect() { $gtma_redirects = get_option('gtma_sso_redirects', array()); $ids = array_keys($gtma_redirects); $token = $this->get_token(); $portalURL = get_option('gtma_portal_url', ''); $id = get_the_ID(); if ((in_array($id, $ids)) && !empty($token) && !empty($portalURL)) { $link = "https://" . $portalURL . "/sso?token=" . urlencode($token) . "&page=" . $gtma_redirects[$id]; wp_redirect($link); exit; } } }