Notifications
Clear all

[Solved] Show Ads only to Unregistered Users

8 Posts
2 Users
3 Reactions
1,036 Views
st7878
Posts: 24
Topic starter
(@st7878)
Eminent Member
Joined: 3 years ago

And, is it possible to show ads only to unregistered users?

7 Replies
st7878
Posts: 24
Topic starter
(@st7878)
Eminent Member
Joined: 3 years ago

I want to buy wpForo Ads Manager. But I need to know if it is possible to disable ads for registered users (logged in to the account). So that the advertisement is visible only to unregistered users.

Kyle
Posts: 728
 Kyle
(@kylew)
Prominent Member
Joined: 3 years ago

Hi @st7878,

Sorry for late response, Yes you can do that.

st7878
Posts: 24
Topic starter
(@st7878)
Eminent Member
Joined: 3 years ago

Hello. I bought this addon. Super! Thanks!

There is one question. I see such errors in the console (see screenshot). This is fine?

Error
1 Reply
Kyle
 Kyle
(@kylew)
Joined: 3 years ago

Prominent Member
Posts: 728

@st7878,

The error is not related to wpForo, check the Google documentations about AdSense for more information.

st7878
Posts: 24
Topic starter
(@st7878)
Eminent Member
Joined: 3 years ago

So that there is no such mistake

"adsbygoogle.push() error: Only one AdSense head tag supported per page. The second tag is ignored."

Сan anyone come in handy. Google generates a code with a script that is already on the site. Therefore, the script itself does not need to be inserted into the declaration. Google gives this code:

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9054324840403095"
     crossorigin="anonymous"></script>
<!-- Медийное горизонтальное -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-9054324840403095"
     data-ad-slot="7010327644"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

but you need to insert this:

<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-9054324840403095"
     data-ad-slot="7010327644"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
2 Replies
Kyle
 Kyle
(@kylew)
Joined: 3 years ago

Prominent Member
Posts: 728

@st7878,

1. Download and Install "Code Snippets" Plugin for WordPress

2. Open Dashboard > Snippets > Add New 

3. Write a Title

4. Add the Below Code, Check the "Only run on site front-end" Checkbox and press Save Changes and Activate

add_action( 'wp_footer', function () { ?>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9054324840403095"
     crossorigin="anonymous"></script>

<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php } );

5. Insert the below HTML Code in the banner you created for the ads from Dashboard > Forums > Ad Manager > Current Banner

<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-9054324840403095"
     data-ad-slot="7010327644"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
st7878
(@st7878)
Joined: 3 years ago

Eminent Member
Posts: 24

@kylew so only shows one ad. since the first script is global and the second script must come with every ad. my version (above) works great.

Share:
Scroll to top