Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #7198
    Fisio
    Participant

    Hello,

    we recently used user role editor to restrict view to logged only user.
    it is working like a charm for most pages.

    Only not working with archive page templated with elementor.
    Like if elementor was charging first, then user role editor ( only the structure appear, not the post inside)

    is there a way so solve that ?

    #7201
    Vladimir
    Keymaster

    Hi,

    Is it possible to look at your site with administrator privileges? If Yes, send credentials and noted page link to support [at-sign] role-editor.com

    #7202
    Fisio
    Participant

    sure i send them to you

    #7204
    Vladimir
    Keymaster

    Thanks. I logged-in successfully. Send the link of the page which we test.

    #7206
    Fisio
    Participant

    any archive like /cat/tutoriels/

    #7208
    Vladimir
    Keymaster

    Thank you for clarification.
    Somehow I missed taxonomy listing pages, like /category/some_cat, or similar. It’s not possible currently to manage view access to such pages itself, only to their content, via view access settings for the posts and/or categories.

    It’s a subject for further development/enhancement.

    #7209
    Fisio
    Participant

    Hey Vladimir, Thanks for getting back to me.

    Is there a way i can’t fix it in the gap time ?
    Like inserting a shortcode inside the template for example ?
    or a code snippet ?

    #7214
    Vladimir
    Keymaster

    I will prepare a piece of code to redirect not logged-in visitor from the custom URL (1-2 days).

    #7215
    Fisio
    Participant

    Awesome,
    thanks

    #7219
    Vladimir
    Keymaster

    This script placed into functions.php file of the active theme of added as a Must Use plugin will redirect not logged-in user to the wp-login.php page:

    
    // Block URLs from the list for not logged-in users
    add_action('wp_head', 'your_prefix_protect_urls', 110);
    
    function your_prefix_protect_urls() {
        
        if ( is_user_logged_in() ) {
            return;
        }
        
        $blocked_paths = array(
          '/wp-test2/category/post-category-1/'  
        );
        
        $redirect = false;
        $path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
        foreach( $blocked_paths as $blocked_path ) {
            if ( $blocked_path==$path ) {
                $redirect = true;
                break;
            }
        }
        
        if ( !$redirect ) {
            return;
        }
    
        // URL where do you wish redirect not logged-in user
        $redirect_to = '/wp-test2/wp-login.php';
        
        if (headers_sent()) {
    ?>
    <script>
        document.location.href = '<?php echo $redirect_to; ?>';
    </script>    
    <?php
            } else {
                wp_redirect( $redirect_to );
            }
            die;
    
        
    }
    

    Just replace blocked path from ‘/wp-test2/category/post-category-1/’ to yours, like ‘/cat/tutoriels/’, and $redirect_to value to from ‘/wp-test2/wp-login.php’ to the path/URL of your login page.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.