Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › Restrict access + elementor template
Tagged: elementor
- This topic has 9 replies, 2 voices, and was last updated 4 years ago by Vladimir.
-
AuthorPosts
-
11/12/2020 at 12:44 #7198FisioParticipant
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 ?
12/12/2020 at 02:46 #7201VladimirKeymasterHi,
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
12/12/2020 at 20:12 #7202FisioParticipantsure i send them to you
14/12/2020 at 13:44 #7204VladimirKeymasterThanks. I logged-in successfully. Send the link of the page which we test.
15/12/2020 at 09:10 #7206FisioParticipantany archive like /cat/tutoriels/
15/12/2020 at 12:34 #7208VladimirKeymasterThank 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.
15/12/2020 at 12:58 #7209FisioParticipantHey 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 ?16/12/2020 at 12:55 #7214VladimirKeymasterI will prepare a piece of code to redirect not logged-in visitor from the custom URL (1-2 days).
16/12/2020 at 13:22 #7215FisioParticipantAwesome,
thanks17/12/2020 at 04:10 #7219VladimirKeymasterThis 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.
-
AuthorPosts
- You must be logged in to reply to this topic.