• Resolved reart2

    (@reart2)


    Hello!
    Many thanks for your work and very useful plugin for my University!

    I need to limit access to Knowledge Base (Echo plugin) – it is a lot of sub-pages after slug “dokumentacja” in URL structure.

    Now I have to show on configuration – list of many, many sub-pages after SLUG wich is not accessible without loging to CAS.

    I’d like to have for example checkbox for slug that all sub-pages after this SLUG will also be accessible ONLY after logging to CAS.

    Maybe it is possible now but I do not see it in configuration options.

    many greetings – Artur

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Paul Ryan

    (@figureone)

    Aloha Artur, you should have two options here:

    1. In Authorizer Settings, on the Public Access tab, set “Who can view the site?” to “Only logged in users can see the site” and then specify which pages should be visible to anonymous users in the list below. This method might not work well if you have a lot of public content and just want to limit access to a specific subset of the site like knowledgebase content. If that’s the case, try the following:
    2. Hook into authorizer_has_access and deny access for anonymous users if the URL slug starts with dokumentatacja:
    add_filter( 'authorizer_has_access', function ( $has_access, $wp ) {
    	// Require logins for anything under /dokumentacja.
    	if ( 
    		! is_user_logged_in() &&
    		! empty( $wp->request ) && 
    		0 === strpos( $wp->request, 'dokumentacja' ) 
    	) {
    		$has_access = false;
    	}
    
    	return $has_access;
    }, 10, 2 );
    
    Thread Starter reart2

    (@reart2)

    SUPER! Thank you for your fast reply and support.
    But I am not a programmist – how to implement your code?
    In PHP – WP, Theme, plugin KB?
    Do I have to make Child Theme fot this purpose?

    Plaese answer for my questions above. Artur

    Plugin Author Paul Ryan

    (@figureone)

    Typically you add these small code snippets in functions.php in your theme or child theme, but you can also use a code snippet plugin so you can add them via the admin dashboard.

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

    Plugin Author pkarjala

    (@pkarjala)

    Thank you again for your question; we are marking this topic resolved. If you still need assistance on this, please let us know!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘CAS – how to simply limit access to sub-pages in structure tree for KB plugin’ is closed to new replies.