• Resolved abdu11ah

    (@abdu11ah)


    Hello,
    I was going through my Ultimate member settings and after i was done with setting stuff up, i visited the site which did not load and the page displayed an error message saying too many redirects. I tried disabling the cache, playing around with the ultimate member settings but it didnt fix the issue. I tried checking the plugins to see if thats what was causing and turns out, the website runs normally when i deactivate the Ultimate member plugin.

    Is there anything i can do the plugin to solve this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • @abdu11ah

    You can try this code snippet, which will write to /wp-content/debug.log the source of your redirects.

    add_filter( 'x_redirect_by', 'wp_redirect_custom_log', 10, 3 );
    
    function wp_redirect_custom_log( $x_redirect_by, $location, $status ) {
    
        $traces = debug_backtrace( DEBUG_BACKTRACE_PROVIDE_OBJECT );
        $plugin_trace = array();
    
        foreach ( $traces as $trace ) {
            if( isset( $trace['file'] )) {
    
                if ( strpos( $trace['file'], '/plugins/' ) > 0 ) {
                    $file = explode( '/plugins/', $trace['file'] );
                    if( substr( $file[1], 0, 22 ) != 'wp_redirect_custom_log' ) {
                        $plugin_trace[] = $file[1] . ':' . $trace['line'];
                    }
                } 
    
                if ( strpos( $trace['file'], '/themes/' ) > 0 ) {
                    $file = explode( '/themes/', $trace['file'] );
                    $plugin_trace[] = 'T: ' . $file[1] . ':' . $trace['line'];
                }
    
                if ( strpos( $trace['file'], '/wp-includes/' ) > 0 ) {
                    $file = explode( '/wp-includes/', $trace['file'] );
                    $plugin_trace[] = 'WP: ' . $file[1] . ':' . $trace['line'];
                }
            }
        }
    
        $trace = date_i18n( 'Y-m-d H:i:s ', current_time( 'timestamp' ));
        $trace .= 'redirect by ' . $x_redirect_by . ', ' . $location . ', ' .  $status . ', ';
        $trace .= 'stack trace: ' . implode( ', ', $plugin_trace );
        file_put_contents( WP_CONTENT_DIR . '/debug.log', $trace . chr(13), FILE_APPEND  );
    
        return $x_redirect_by;
    }

    Add the code snippet to your active theme’s/child-theme’s functions.php file
    or use the “Code Snippets” plugin.

    https://wordpress.org/plugins/code-snippets/

    Plugin Support andrewshu

    (@andrewshu)

    Hi @abdu11ah

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. 🙂

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Error: Too many redirects’ is closed to new replies.