Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.0k views
in Plugins by
I know there are some good ads plugins available but can there be one more feature where ads will just be shown to non logged in users. And as soon as users login the ads should disappear.

Means if the user is logged in then there should be no ads, but as soon as the users log out then he will be seeing ads again.
by
what is the benifit you get out of this
by
Bro the benefit is to make money from visitors only, without reducing user experience of our users.
by
good idea i like it :)
by
It's easy. which plugin do you use?
by
I use simple advert plugin for showcasing ads.
by
The @q2apro.com's answer is right

1 Answer

+3 votes
by
Use an advanced theme: qa-theme.php

Overwrite:

        function a_list($a_list) {
            if(!qa_is_logged_in() && $this->template!='qa') {

                // google ads
                $this->output('
                <div class="adholder-mid">
                    <script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                    <ins class="adsbygoogle"
                         style="display:inline-block;width:728px;height:90px"
                         data-ad-client="ca-pub-123456789"
                         data-ad-slot="55123456789"></ins>
                    <script>
                    (adsbygoogle = window.adsbygoogle || []).push({});
                    </script>
                </div>
                ');
            }
            
            // call default method output
            qa_html_theme_base::a_list($a_list);
        }
by
Thanks for you answer Kai. I'll try this.
...