Do not show ads to post-related membergroup.

Started by _Ziggy_, November 13, 2009, 03:11:09 PM

Previous topic - Next topic

_Ziggy_

I am using AdSense on my forum.
The forum also has a "0 posts" membergroup who can see just 1 board, the "introduce yourself board".
Because there's only one board for those members, they get to see a lot of ads. This is very anoying so I want to exclude some of the ads for the "0 posts" membergroup.

What do I have to ad to my code, (the "0 posts" membergroup is membergroup 4).
This is the code that I am using for the ads:

echo '
  <div><br /><script type="text/javascript"><!--
google_ad_client = "pub-*************************";
/* 728x90, gemaakt 28-2-09 na infocenter */
google_ad_slot = "7162697257";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
  ';
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

_Ziggy_

I am using this code now:


if (in_array(0,1,2,3,4,5,6,7,8,9,10,11,12, $user_info['groups']))   
{
echo '
  <div><br /><script type="text/javascript"><!--
google_ad_client = "pub-*************************";
/* 728x90, gemaakt 28-2-09 na infocenter */
google_ad_slot = "7162697257";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
   ';   
   }
   else   
   {       
   echo 'geen advertentie!';
   }


I cannot figure out why the ads never show up.
I have a testaccount which is a member of post-related-group 4, but it stil shows 'geen advertentie" instead of the ad.
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor

Try that first line as:
if (in_array(array(0,1,2,3,4,5,6,7,8,9,10,11,12), $user_info['groups']))

You might consider reducing that list; 1 = admin, 2 = global moderator.

_Ziggy_

Thanks for your very fast answer!

I have reduced the line (it is just a testforum).

Now it is like this:
if (in_array(array(2,3,4,5,6), $user_info['groups'])) 

The ad still doesn't show up to my test account which is in group 4.

Here is a larger part of the code from the index.template:
// Show the menu here, according to the menu sub template.
template_menu();

//Google Adsense
if (in_array(array(2,3,4,5,6), $user_info['groups'])) 
{
echo '
  <div><br /><script type="text/javascript"><!--
google_ad_client = "pub-0096549331063923";
/* Bluesforum.com 728x90, gemaakt 28-2-09 na infocenter */
google_ad_slot = "7162697257";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
   ';   
   }
   else   
   {       
   echo 'geen advertentie!';
   }
// Google Adsense

echo '
<br class="clear" />';

// Show the navigation tree.
theme_linktree();

echo '
</div></div>';

// The main content should go here.
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor

OK, just for testing purposes, before the if(in_array())... add print_r($user_info['groups']) to see a list of what groups the user is allegedly part of.

_Ziggy_

I have tried adding that, but the list doesn't show up.

This is the code now:

//Google Adsense
   print_r($user_info['groups']);
if (in_array(array(2,3,4,5,6), $user_info['groups'])) 
{
echo '
  <div><br /><script type="text/javascript"><!--
google_ad_client = "pub-0096549331063923";
/* Bluesforum.com 728x90, gemaakt 28-2-09 na infocenter */
google_ad_slot = "7162697257";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
   ';   
   }
   else   
   {   
   echo 'geen advertentie!!';
   }
// Einde Adsense
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor


_Ziggy_

#7
Yes, a lot:

QuoteGuest
********************
    Today at 07:04:30 PM
b64d34ecb76604d1e37ebf4db37a7147
Type of error: General 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated2: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argumentFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Errors.template.php (body_above sub template - eval?)
Line: 323 
   Guest
********************
    Today at 07:04:30 PM
b64d34ecb76604d1e37ebf4db37a7147
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated8: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Errors.template.php (body_above sub template - eval?)
Line: 323 
   Guest
********************
    Today at 07:04:30 PM
b64d34ecb76604d1e37ebf4db37a7147
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated8: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Errors.template.php (body_above sub template - eval?)
Line: 322 
   Guest
******************** 
    Today at 07:04:28 PM
cff9ee7166a26a48bbf873cde30867d0
Type of error: General 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated2: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argumentFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Errors.template.php (body_above sub template - eval?)
Line: 323 
   Guest
********************
    Today at 07:04:28 PM
cff9ee7166a26a48bbf873cde30867d0
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated8: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Errors.template.php (body_above sub template - eval?)
Line: 323 
   Guest
********************
    Today at 07:04:28 PM
cff9ee7166a26a48bbf873cde30867d0
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated8: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Errors.template.php (body_above sub template - eval?)
Line: 322 
   Ziggy
********************
    Today at 07:04:27 PM
e38d5c8edd7bce7df4f311bf0e84f715
Type of error: General 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated2: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argumentFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/GenericMenu.template.php (body_above sub template - eval?)
Line: 323 
   Ziggy
********************
    Today at 07:04:27 PM
e38d5c8edd7bce7df4f311bf0e84f715
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated8: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/GenericMenu.template.php (body_above sub template - eval?)
Line: 323 
   Ziggy
********************
    Today at 07:04:27 PM
e38d5c8edd7bce7df4f311bf0e84f715
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;updated8: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/GenericMenu.template.php (body_above sub template - eval?)
Line: 322 
   Guest
********************
    Today at 07:04:12 PM
2a038db96779fd1f5e2da6fee96e3ff8
Type of error: General 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;u=12: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argumentFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Login.template.php (body_above sub template - eval?)
Line: 323 
   Guest
******************** 
    Today at 07:04:12 PM
2a038db96779fd1f5e2da6fee96e3ff8
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;u=18: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Login.template.php (body_above sub template - eval?)
Line: 323 
   Guest
********************
    Today at 07:04:12 PM
2a038db96779fd1f5e2da6fee96e3ff8
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;u=18: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Login.template.php (body_above sub template - eval?)
Line: 322 
   Guest
********************
    Today at 07:04:10 PM
1d0aad0ce027b4c3293b63987d200214
Type of error: General 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;u=12: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argumentFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Login.template.php (body_above sub template - eval?)
Line: 323 
   Guest
********************
    Today at 07:04:10 PM
1d0aad0ce027b4c3293b63987d200214
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;u=18: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Login.template.php (body_above sub template - eval?)
Line: 323 
   Guest
********************   
    Today at 07:04:10 PM
1d0aad0ce027b4c3293b63987d200214
Type of error: Undefined 
http://www.bluesforum.com/testforum2.0rc1/index.php?action=profile;area=account;u=18: Undefined variable: user_infoFile: /chroot/home/bluesfor/bluesforum.com/html/testforum2.0rc1/Themes/default/Login.template.php (body_above sub template - eval?)
Line: 322 
  Check all 
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor


_Ziggy_

Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor

Hmm, curious then. Seems to be saying that $user_info['groups'] isn't an array, which is very weird indeed, since it should ALWAYS be an array with at least two items in.

_Ziggy_

I have switched the forumlanguage to English and added a new error log to the post above.
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor

Ahhhhh.

Add global $user_info; above the code in question.

_Ziggy_

Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor

Hm.

What happens if you make that print_r into var_dump, i.e. var_dump($user_info['groups']) ?

_Ziggy_

Now there's this result for my test-account:
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor

So there's no type juggling.

Hmm, weird, very weird, unless I'm misreading what the description of in_array is supposed to do when matching an array (since I rarely use that function)

Should be doable with: (rearranging and tweaking for performance)
if (in_array(4, $user_info['groups']) || in_array(2, $user_info['groups']) || in_array(5, $user_info['groups']) || in_array(6, $user_info['groups']))

You could have it apply to 0 first actually since that's all regular members (including all post count groups); only those who don't have an assigned primary group (like admin, global moderator) would have 0 as a group. Also group 3 isn't a real group.

Marsh

Quote from: Arantor on November 21, 2009, 03:05:02 PM
So there's no type juggling.

Hmm, weird, very weird, unless I'm misreading what the description of in_array is supposed to do when matching an array (since I rarely use that function)

Should be doable with: (rearranging and tweaking for performance)
if (in_array(4, $user_info['groups']) || in_array(2, $user_info['groups']) || in_array(5, $user_info['groups']) || in_array(6, $user_info['groups']))

You could have it apply to 0 first actually since that's all regular members (including all post count groups); only those who don't have an assigned primary group (like admin, global moderator) would have 0 as a group. Also group 3 isn't a real group.

Worked great for me, thanks.
625,195 Posts in 50,808 Topics by 34,295 Members.

Powered by SMF 2.0

www.touchofdeathproductions.com

_Ziggy_

That did the job!!!!!!!!!!

Thanks for solving the problem.
Bluesforum.com   2.0                     Bluesforum.nl   2.0
Rockabilly-forum.com   2.0              Bluesharp.nl   2.0
Bungalowpark-forum.nl   2.0        Eee pad forum   2.01
Cristiano Ronaldo   2.02              Lockout Tagout   2.02


Looking to buy existing forums, send pm.

Arantor

You can take the var_dump line out now we figured out the problem :)

Good to see it's working though.

Advertisement: