• Resolved pzeylstra

    (@pzeylstra)


    I’ve set up members to make it possible to hide a page that is only meant for members. However, when I follow the url of the page that should be hidden it is still visible. I checked on the relevant page that you have to log in to access it. Can’t find what is wrong.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @pzeylstra

    Could you switch to default WordPress theme like Twenty Twenty Four and see if that issue persists?

    If that does not help, you could try to use the code snippet below to protect the page and redirect unauthorized users to different page:

    add_action( 'template_redirect', function () {
    	// Redirect users from specific page
    	// when user doesn't have particular role
    	$user = wp_get_current_user();
    	if ( is_page( 'your-page-slug' ) ) return;
    	if ( ! is_user_logged_in() ) return;
        if ( ! empty( $user ) && in_array( 'author', (array) $user->roles ) ) {
    		$redirect = 'https://your-domain.com/wp-login.php'; // Change this to the correct URL
    		wp_redirect( $redirect );
    		exit;
    	}
    } );

    I hope that helps.

    Thread Starter pzeylstra

    (@pzeylstra)

    I switched the theme and the restriction does work when I do. So it is the Bricks theme that is causing the issue. With your suggestion I now have 4 options as meanwhile Bricks has replied as following:

    “The plugin works as expected, as it restricts the post_content (from Gutenberg). The Bricks content needs to be rendered separately and in a different way, and the plugin can’t know about that.

    You have three possibilities to restrict the content or parts of the content (e.g. the calendar shortcode).

    1) Wrap it with the [members_access] Shortcode: https://members-plugin.com/docs/shortcodes/

    2) Add the content you want to restrict to Gutenberg and inside of the Bricks content, use the post content element to output the Gutenberg content (which will be restricted then).
    3) Use the Bricks conditions instead of the plugin to restrict to specific user groups.”

    I hope this also helps others who are struggling with this.

    Thank you for you help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Restricted page still visible’ is closed to new replies.