function makeRedirect($type, am4_Settings_Abstract $settings, $is_category = false) { // Do not make redirect if wordpress is included from amember in order to avoid redirect loops. if (defined('AM_VERSION')) { return; } $is_cat = $is_category ? "_cat" : ""; $api = am4PluginsManager::getAPI(); $action = $settings->{$type . '_action' . $is_cat}; if (empty($action)) { $action = 'login'; } switch ($action) { case 'page': $url = get_page_link($settings->{$type . '_action' . $is_cat . '_page'}); break; case 'redirect': $url = $settings->{$type . '_action' . $is_cat . '_redirect' . $is_cat}; break; case 'login': $url = $api->isLoggedIn() ? $api->getSignupURL() : am4PluginsManager::getLoginURL(true); break; default: $url = false; } // not redirect action; if ($url === false) { return; } if (!headers_sent()) { if (!$url) { $url = get_site_url(); } wp_redirect($url); exit; } else { throw new Exception(__("Headers already sent! Can't redirect.", 'am4-plugin')); } }