• Resolved brunosette

    (@brunosette)


    Hello everyone,

    I am hoping someone can help me troubleshoot an issue I am experiencing with my WordPress website that is using the Ultimate Member plugin.

    Some of my users are being redirected to the login area when they try to open specific posts, even though these posts should be accessible to all users. The strange thing is that this issue is only occurring for some users and there seems to be no rhyme or reason for it.

    I have tried to identify any commonalities between the users experiencing the issue, but so far, I have been unable to find any. I have also checked the plugin settings and the post permissions, and everything seems to be in order.

    If anyone has experienced a similar issue or has any suggestions for what I can do to fix this, I would greatly appreciate your input.

    Thank you in advance for your help!

    Best regards,

    Bruno

    Screen capture of the problem: https://drive.google.com/file/d/1q8E51fjQgc_xl1r66n2ydMcXAWEATDjl/view?usp=share_link

Viewing 15 replies - 1 through 15 (of 26 total)
  • @brunosette

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

    Make notes of the time when you get a bad redirect and post that part of the log file here in the Forum and we can give you an explanation of the redirect.

    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'] ) && 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'];
                }
            }
        }
    
        $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://www.ads-software.com/plugins/code-snippets/

    • This reply was modified 1 year, 7 months ago by missveronica.
    Thread Starter brunosette

    (@brunosette)

    2023-04-17 21:53:25 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/, stack trace:
    2023-04-17 22:04:45 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos/, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-04-17 22:06:00 redirect by WordPress, 302, /nefroupdates/wp-login.php?checkemail=confirm, stack trace:

    @brunosette

    Redirect to your Login page is made by UM, no plugin conflict issue.

    Have you tried to activate/deactivate the “Disable pre-queries for restriction content logic (advanced)” at UM Settings -> Misc ?

    Thread Starter brunosette

    (@brunosette)

    I did activate the “Disable pre-queries for restriction content logic (advanced)”?as you suggested but didn’t make any difference.

    Can you check this log please?

    2023-04-18 16:03:13 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos/?redirect_to=https%3A%2F%2Fwww.nefroatual.com.br%2Fnefroupdates%2Fqual-meta-pressorica-na-sindrome-hepatorrenal%2F, stack trace: ultimate-member/includes/core/class-access.php:1790, ultimate-member/includes/core/class-access.php:1531

    @brunosette

    Have you any customizations in your active theme’s functions.php file?

    You can exclude the customizations by changing to a default WP Theme like “Twenty Twenty-Two”.

    Thread Starter brunosette

    (@brunosette)

    No, I didn’t make any customization to my theme.

    @brunosette

    Do you have Users with multiple Roles?

    Thread Starter brunosette

    (@brunosette)

    No, they are all subscribers

    @brunosette

    You can try this code snippet to avoid the redirect to login page and user is being redirected to the user page instead.

    add_action( 'template_redirect', 'um_restrict_login_page_logged_in' );
    
    	function um_restrict_login_page_logged_in() {
    
    		if ( function_exists( 'um_is_core_page' ) && um_is_core_page( 'login' ) && is_user_logged_in() ) {
    			wp_redirect( um_get_core_page( 'user' ) );
    			exit;
    		}
    	}

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

    https://www.ads-software.com/plugins/code-snippets/

    • This reply was modified 1 year, 7 months ago by missveronica.
    Thread Starter brunosette

    (@brunosette)

    I added the code, but the problem still the same…

    Please help!

    @brunosette

    Try to change the priority to 99999 by changing this line:

    add_action( 'template_redirect', 'um_restrict_login_page_logged_in', 99999 );

    Thread Starter brunosette

    (@brunosette)

    Unfortunately, made no difference.

    Thread Starter brunosette

    (@brunosette)

    Anyone?

    @brunosette

    Enable PHP error logging if the debug logging will give some more info about your issue.

    Read this guide: “How to enable debug logging”

    https://docs.ultimatemember.com/article/1751-enable-debug-logging

    You will probably get a PHP log file with notices and errors in this file:
    /wp-content/debug.log

    Post the content of this file here in the Forum and we can give you the PHP error explanation. For best formatting use the CODE format.

    Thread Starter brunosette

    (@brunosette)

    2023-05-03 19:22:46 redirect by WordPress, 302, https://www.nefroatual.com.br/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 19:22:47 redirect by WordPress, 302, https://www.nefroatual.com.br/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 19:25:35 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/, stack trace:
    2023-05-03 19:25:36 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/, stack trace:
    2023-05-03 19:29:43 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/wp-admin/post.php?post=1426&action=edit&message=4, stack trace:
    2023-05-03 19:40:30 redirect by WordPress, 302, https://www.nefroatual.com.br/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 19:41:18 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 19:41:19 redirect by WordPress, 301, https://www.nefroatual.com.br/nefroupdates/planos/, stack trace:
    2023-05-03 19:41:35 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/, stack trace:
    2023-05-03 19:42:20 redirect by WordPress, 302, /nefroupdates/wp-login.php?action=rp&wp_lang=pt_BR, stack trace:
    2023-05-03 19:43:03 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates, stack trace:
    2023-05-03 19:49:29 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 19:49:30 redirect by WordPress, 301, https://www.nefroatual.com.br/nefroupdates/planos/, stack trace:
    2023-05-03 19:49:56 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/, stack trace:
    2023-05-03 19:54:42 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos/, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 19:56:13 redirect by WordPress, 302, https://www.nefroatual.com.br/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 20:28:43 redirect by WordPress, 302, https://www.nefroatual.com.br/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 20:29:08 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 20:29:09 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 20:29:10 redirect by WordPress, 301, https://www.nefroatual.com.br/nefroupdates/planos/, stack trace:
    2023-05-03 20:30:08 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/, stack trace:
    2023-05-03 20:31:17 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/wp-admin/post.php?post=1409&action=edit&message=4, stack trace:
    2023-05-03 20:44:28 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
    2023-05-03 20:44:28 redirect by WordPress, 301, https://www.nefroatual.com.br/nefroupdates/planos/, stack trace:
    2023-05-03 22:10:50 redirect by WordPress, 302, https://www.nefroatual.com.br/nefroupdates/planos, stack trace: ultimate-member/includes/core/class-access.php:1414
Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘User redirect to login in some specific posts’ is closed to new replies.