Пример #1
0
function pmpro_besecure()
{
    global $besecure, $post;
    //check the post option
    if (!is_admin() && !empty($post->ID) && !$besecure) {
        $besecure = get_post_meta($post->ID, "besecure", true);
    }
    //if forcing ssl on admin, be secure in admin and login page
    if (!$besecure && force_ssl_admin() && (is_admin() || pmpro_is_login_page())) {
        $besecure = true;
    }
    //if forcing ssl on login, be secure on the login page
    if (!$besecure && force_ssl_login() && pmpro_is_login_page()) {
        $besecure = true;
    }
    $besecure = apply_filters("pmpro_besecure", $besecure);
    $use_ssl = pmpro_getOption("use_ssl");
    if ($use_ssl == 1) {
        if ($besecure && (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off" || $_SERVER['HTTPS'] == "false")) {
            //need to be secure
            wp_redirect("https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        } elseif (!$besecure && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" && $_SERVER['HTTPS'] != "false") {
            //don't need to be secure
            wp_redirect("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
            exit;
        }
    }
}
Пример #2
0
function pmpro_redirect_to_logged_in()
{
    if ((pmpro_is_login_page() || is_page("login")) && !empty($_REQUEST['redirect_to']) && is_user_logged_in() && (empty($_REQUEST['action']) || $_REQUEST['action'] == 'login')) {
        wp_redirect($_REQUEST['redirect_to']);
        exit;
    }
}
Пример #3
0
function pmpro_login_head()
{
    $login_redirect = apply_filters("pmpro_login_redirect", true);
    if ((pmpro_is_login_page() || is_page("login")) && $login_redirect) {
        //redirect registration page to levels page
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == "register" || isset($_REQUEST['registration']) && $_REQUEST['registration'] == "disabled") {
            //redirect to levels page unless filter is set.
            $link = apply_filters("pmpro_register_redirect", pmpro_url("levels"));
            if (!empty($link)) {
                wp_redirect($link);
                exit;
            } else {
                return;
            }
            //don't redirect if pmpro_register_redirect filter returns false or a blank URL
        }
        //if theme my login is installed, redirect all logins to the login page
        if (pmpro_is_plugin_active("theme-my-login/theme-my-login.php")) {
            //check for the login page id and redirect there if we're not there already
            global $post;
            if (is_array($GLOBALS['theme_my_login']->options)) {
                //an older version of TML stores it this way
                if ($GLOBALS['theme_my_login']->options['page_id'] !== $post->ID) {
                    //redirect to the real login page
                    $link = get_permalink($GLOBALS['theme_my_login']->options['page_id']);
                    if ($_SERVER['QUERY_STRING']) {
                        $link .= "?" . $_SERVER['QUERY_STRING'];
                    }
                    wp_redirect($link);
                    exit;
                }
            } elseif (!empty($GLOBALS['theme_my_login']->options)) {
                //another older version of TML stores it this way
                if ($GLOBALS['theme_my_login']->options->options['page_id'] !== $post->ID) {
                    //redirect to the real login page
                    $link = get_permalink($GLOBALS['theme_my_login']->options->options['page_id']);
                    if ($_SERVER['QUERY_STRING']) {
                        $link .= "?" . $_SERVER['QUERY_STRING'];
                    }
                    wp_redirect($link);
                    exit;
                }
            } elseif (class_exists("Theme_My_Login") && version_compare(Theme_My_Login::version, "6.3") >= 0) {
                //TML > 6.3
                $link = Theme_My_Login::get_page_link("login");
                if (!empty($link)) {
                    //redirect if !is_page(), i.e. we're on wp-login.php
                    if (!Theme_My_Login::is_tml_page()) {
                        wp_redirect($link);
                        exit;
                    }
                }
            }
            //make sure users are only getting to the profile when logged in
            global $current_user;
            if (!empty($_REQUEST['action']) && $_REQUEST['action'] == "profile" && !$current_user->ID) {
                $link = get_permalink($GLOBALS['theme_my_login']->options->options['page_id']);
                wp_redirect($link);
                exit;
            }
        }
    }
}
Пример #4
0
function pmpro_login_head()
{
	$login_redirect = apply_filters("pmpro_login_redirect", true);
	if((pmpro_is_login_page() || is_page("login")) && $login_redirect)
	{
		//redirect registration page to levels page
		if(isset($_REQUEST['action']) && $_REQUEST['action'] == "register" || isset($_REQUEST['registration']) && $_REQUEST['registration'] == "disabled")
		{
			//redirect to levels page unless filter is set.
			$link = apply_filters("pmpro_register_redirect", pmpro_url("levels"));
			if(!empty($link))
			{
				wp_redirect($link);
				exit;
			}
			else
				break;	//don't redirect if pmpro_register_redirect filter returns false or a blank URL
		}

		//if theme my login is installed, redirect all logins to the login page
		if(pmpro_is_plugin_active("theme-my-login/theme-my-login.php"))
		{
			//check for the login page id and redirect there if we're not there already
			global $post;
			if(is_array($GLOBALS['theme_my_login']->options))
			{
				if($GLOBALS['theme_my_login']->options['page_id'] !== $post->ID)
				{
					//redirect to the real login page
					$link = get_permalink($GLOBALS['theme_my_login']->options['page_id']);
					if($_SERVER['QUERY_STRING'])
						$link .= "?" . $_SERVER['QUERY_STRING'];
					wp_redirect($link);
					exit;
				}
			}
			elseif(!empty($GLOBALS['theme_my_login']->options))
			{
				if($GLOBALS['theme_my_login']->options->options['page_id'] !== $post->ID)
				{
					//redirect to the real login page
					$link = get_permalink($GLOBALS['theme_my_login']->options->options['page_id']);
					if($_SERVER['QUERY_STRING'])
						$link .= "?" . $_SERVER['QUERY_STRING'];
					wp_redirect($link);
					exit;
				}
			}

			//make sure users are only getting to the profile when logged in
			global $current_user;
			if(!empty($_REQUEST['action']) && $_REQUEST['action'] == "profile" && !$current_user->ID)
			{
				$link = get_permalink($GLOBALS['theme_my_login']->options->options['page_id']);
				wp_redirect($link);
			}
		}
	}
}