Skip to content

Commit

Permalink
Remove redirect_to query arg from redirect URL's to prevent infinit…
Browse files Browse the repository at this point in the history
…e loop
  • Loading branch information
Václav Greif committed Sep 16, 2019
1 parent efc09d1 commit bd42ea5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function __construct( Settings $settings ) {
* @return mixed
*/
public function login_redirect( $redirect, $request, $user ) {

if ( $redirect_url = $this->settings->ssc_get_option( 'ssc_redirect_url' ) ) {
$redirect = $redirect_url;
$redirect_url = $this->settings->ssc_get_option( 'ssc_redirect_url' );
if ( $redirect_url ) {
$redirect = remove_query_arg( [ 'redirect_to' ], $redirect_url );;
}

return $redirect;
Expand All @@ -70,7 +70,7 @@ public function check_access() {

// Check if current user has access to the post, if not, redirect him to defined URL or home if the URL is not set
if ( $post_groups && ! $this->user_can_view_post() && ! is_home() && ! is_front_page() ) {
$no_access_url = $this->get_no_access_redirect_url();
$no_access_url = remove_query_arg( [ 'redirect_to' ], $this->get_no_access_redirect_url() );

$main_redirect_url = is_user_logged_in() ? site_url() : wp_login_url();
$url = $no_access_url ?: $main_redirect_url;
Expand Down

0 comments on commit bd42ea5

Please sign in to comment.