Limit access to pages only with internal links

I’m developing a marketplace website based on WordPress, and I have 2 sections of it that I want to make privately accessible only for the parties involved – one is profiles and the other one is projects. I think that the way to do it is to make these pages accessible only through internal links within the website – by doing it like this, I don’t think there’s a possibility for someone unrelated and external to land on a restricted page.

I’ve tried this code from another Stackoverflow question, but it doesn’t work in my case:

/* at the top of page */
    if ( $_SERVER['REQUEST_METHOD']=='GET' && realpath(__FILE__) == realpath( $_SERVER['SCRIPT_FILENAME'] ) ) {
           Up to you which header to send, some prefer 404 even if 
           the files do exist for security
        header( 'HTTP/1.0 404 Not Found', TRUE, 404 );
        /* choose the appropriate page to redirect users */
        die( header( 'location: /404.php' ) );

One of the pages I’m trying to limit access to looks like this:

I’m still new to all this technical stuff, so any help from you on this would be greatly appreciated. Thank you.

Read more here: Limit access to pages only with internal links

Leave a Reply

Your email address will not be published. Required fields are marked *