Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
183 views
in Plugins by
I'm looking for a way to hide the answer (or at least part of it) from unregistered visitors

It only appears after the person has registered
by
Like all the answers or only the best selected answer?
by
All answers not just best one

2 Answers

+1 vote
by

You'll need to check if the user is Logged in/Registered with a  qa_is_logged_in()  statement. If they are, display the content normally, if not, output a message incentivize them to do so.

Open your qa-theme,php file , and paste the following code:

public function a_item_content($a_item)
{
    if (!isset($a_item['content'])) {
        $a_item['content'] = '';
    }

    $this->output('<div class="qa-a-item-content qa-post-content">');
    if (!qa_is_logged_in()) {
        $this->output('You must <a href="'.qa_path('login').'">Login</a> or <a href="'.qa_path('register').'">Register</a> in order to view this answer!');
    } else {
        $this->output_raw($a_item['content']);
    }
    $this->output('</div>');
}

This assuming you don't have a  a_item_content()  function in this file already. If you have, just make the adjustments based on the code above.


Should look something like this:

by
+1
I mean you could **visually** obfuscate the content with CSS, But anybody with coding skills would still be able to see the content by inspecting the element.
by
Yes, that's fine, even if it's only visual.
Can you set up a plugin or something like that to do the job?
I'm willing to pay for it
by
@Zhao's plugin mentioned on @Bharat's answer pretty much does that job
0 votes
by
https://github.com/ostack/q2a-hide-answers-for-unlogin-user

May be this plugin what you needed ?

try it on demo first
by
What about google?
by
SE spider can see the answer
i am the plugin author ,you checkout it from github and use it freely
...