Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
264 views
in Q2A Core by
edited by
I need a page with content visible for only registered users.

I created a page in the backend with the name: "My Content Page" for registered users only with everything I need.

The idea is to show a "please register to see this content" section, but let anonymous to see page title and header content.

Anonymous: Please register to see this content.

Registered: Here is the content.

How can I achieve this?

Because I only get the "You do not have permission to perform this operation" alert and I want to tell the users to register to see that content.

Thanks.

1 Answer

+1 vote
by

You didn't tell what kind of page "My Content Page" is? Is it a custom page, or just a question page.

If it is the question page, then you need to override public function q_view_main($q_view) in your theme.

Replace $this->q_view_content($q_view); with

       if (qa_is_logged_in()){
        $this->q_view_content($q_view);
        }
        else {
            $this->output('Please register to see this content.');
        }

For custom pages, or even widget content, you will do the same:

if (qa_is_logged_in()){
        //the custom page or widget content here.
        }
        else {
            echo 'Please register to see this content.' ;
        }

by
That looks much more better! Thank you!

Can you just please let me know which file to override in?
by
In your theme. There's a file named qa-theme.php in your theme folder. But I don't think the last trick will work. Best to create a seperate custom page.
by
If you are not keen on coding, you can change the language file into "You either need to register to see this content or you don't have the permission to do so."  Something like that.
by
Thank you for the info.
...