diff --git a/core/um-access.php b/core/um-access.php
index 1e44117a..3a091bce 100644
--- a/core/um-access.php
+++ b/core/um-access.php
@@ -31,7 +31,7 @@ class UM_Access {
if ( strstr( $this->redirect_handler, um_get_core_page('login') ) ){
$curr = $ultimatemember->permalinks->get_current_url();
- $this->redirect_handler = add_query_arg('redirect_to', um_set_redirect_url($curr), $this->redirect_handler);
+ $this->redirect_handler = add_query_arg('redirect_to', urlencode_deep($curr), $this->redirect_handler);
$this->redirect_handler = esc_url( $this->redirect_handler );
}
diff --git a/core/um-account.php b/core/um-account.php
index 826827ac..1f54bbd5 100644
--- a/core/um-account.php
+++ b/core/um-account.php
@@ -77,7 +77,7 @@ class UM_Account {
$redirect_to = add_query_arg(
'redirect_to',
- um_set_redirect_url( um_get_core_page('account') ) ,
+ urlencode_deep( um_get_core_page('account') ) ,
um_get_core_page('login')
);
diff --git a/core/um-actions-login.php b/core/um-actions-login.php
index dcac2ddf..aa9de40b 100644
--- a/core/um-actions-login.php
+++ b/core/um-actions-login.php
@@ -136,7 +136,7 @@
// Priority redirect
if ( isset( $args['redirect_to'] ) ) {
- exit( wp_redirect( um_get_redirect_url( $args['redirect_to'] ) ) );
+ exit( wp_redirect( urldecode( $args['redirect_to'] ) ) );
}
// Role redirect
diff --git a/core/um-actions-misc.php b/core/um-actions-misc.php
index b51dd37d..90a8ee9b 100644
--- a/core/um-actions-misc.php
+++ b/core/um-actions-misc.php
@@ -9,8 +9,8 @@
global $ultimatemember;
if ( isset( $_REQUEST['redirect_to'] ) && !empty( $_REQUEST['redirect_to'] ) ) {
-
- echo '';
+ $url = urlencode_deep( $_REQUEST['redirect_to'] );
+ echo '';
} else if ( isset( $args['after_login'] ) && !empty( $args['after_login'] ) ) {
@@ -33,9 +33,9 @@
break;
}
- $url = esc_attr( um_set_redirect_url( $url ) );
+ $url = urlencode_deep( $url );
- echo '';
+ echo '';
}
diff --git a/core/um-actions-register.php b/core/um-actions-register.php
index 573a267c..3bbb355d 100644
--- a/core/um-actions-register.php
+++ b/core/um-actions-register.php
@@ -188,7 +188,7 @@
// Priority redirect
if ( isset( $args['redirect_to'] ) ) {
- exit( wp_redirect( um_get_redirect_url( $args['redirect_to'] ) ) );
+ exit( wp_redirect( urldecode( $args['redirect_to'] ) ) );
}
if ( $status == 'approved' ) {
diff --git a/core/um-short-functions.php b/core/um-short-functions.php
index 19bd596c..3df0e58a 100644
--- a/core/um-short-functions.php
+++ b/core/um-short-functions.php
@@ -63,7 +63,7 @@
$redirect_to = $ultimatemember->permalinks->get_current_url();
}
- $redirect_key = um_set_redirect_url( $redirect_to );
+ $redirect_key = urlencode_deep( $redirect_to );
$uri = add_query_arg( 'redirect_to', $redirect_key, $uri );
@@ -77,6 +77,10 @@
*/
function um_set_redirect_url( $url ){
+ if( um_is_session_started() === FALSE ){
+ session_start();
+ }
+
$redirect_key = wp_generate_password(12,false);
$_SESSION['um_redirect_key'] = array( $redirect_key => $url );
@@ -91,6 +95,10 @@
*/
function um_get_redirect_url( $key ){
+ if( um_is_session_started() === FALSE ){
+ session_start();
+ }
+
if( isset( $_SESSION['um_redirect_key'][ $key ] ) ){
$url = $_SESSION['um_redirect_key'][ $key ];
@@ -112,6 +120,25 @@
return;
}
+
+ /**
+ * Checks if session has been started
+ * @return bool
+ */
+ function um_is_session_started(){
+
+ if ( php_sapi_name() !== 'cli' ) {
+ if ( version_compare(phpversion(), '5.4.0', '>=') ) {
+ return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE;
+ } else {
+ return session_id() === '' ? FALSE : TRUE;
+ }
+ }
+
+ return FALSE;
+ }
+
+
/***
*** @user clean basename
***/