miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

How To Show/Block specific content (Ads) for guests/members or certain users

 
 
Page  Page 1 of 2:  1  2  Next »

Author michael1234
Partaker
#1 | Posted: 2 Jan 2007 10:45 
Is there a way with Minibb to block ads when members are logged in, and to show ads in the header/footer when not logged in (as a guest)?

Author Paul
Lead Developer 
#2 | Posted: 2 Jan 2007 14:38 
For sure it's possible... few code lines in bb_plugins.php which produce ads variable by the condition $user_id>0, like...

if($user_id==0) $adBlock=<<<out
Put your ad html here
out;
else $adBlock='';

then paste {$adBlock} in templates/main_header.html or whatever....

Author michael1234
Partaker
#3 | Posted: 2 Jan 2007 17:28 
Thanks Paul.

Is there a way that ONLY certain members would NOT see the ads. For example, if I want 50 users not to see the ads , INCLUDING guests, how would I put their ids in there?

Is there a limit to how many users you can in the code?

Author Paul
Lead Developer 
#4 | Posted: 4 Jan 2007 07:04 
The code would be...

$notShowAdsUsers=array(1,2,3);
//specify IDs of users in array above

if($user_id!=0 and !in_array($user_id, $notShowAdsUsers)) $adBlock=<<<out
Put your ad html here
out;
else $adBlock='';


Is there a limit to how many users you can in the code
there is actually a ten thousands limit :-) it only depends on how big your server's memory is. You can specify as many IDs as you want, but be sure this value is not very large... so it doesn't slow the execution time.

Author Anonymous
Guest
#5 | Posted: 6 Jan 2007 20:30 
How do you put these two code together?

#1
==================
$notShowAdsUsers=array(1,2,3);
//specify IDs of users in array above

if($user_id!=0 and !in_array($user_id, $notShowAdsUsers)) $adBlock=<<<out
Put your ad html here
out;
else $adBlock='';
==========================

#2
=============================

function parseMessage(){

//Use $GLOBALS['anchor'] for determining the anchor value
$GLOBALS['adsense']='';

if ($GLOBALS['anchor']==1 or $GLOBALS['anchor']==9){

//You Adsense generated code here
$GLOBALS['adsense'] = <<<out

<script type="text/javascript"><!--
google_ad_client = "pub-XXXXXXXXXXXXXXXX";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "E9EFF4";
google_color_bg = "E9EFF4";
google_color_link = "006699";
google_color_text = "000000";
google_color_url = "006699";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

out;

}

================

Author Paul
Lead Developer 
#6 | Posted: 8 Jan 2007 03:45 
$notShowAdsUsers=array(1,2,3);
//specify IDs of users in array above

function parseMessage(){

//Use $GLOBALS['anchor'] for determining the anchor value
$GLOBALS['adsense']='';

if ( ($GLOBALS['anchor']==1 or $GLOBALS['anchor']==9) and $GLOBALS['user_id']!=0 and !in_array($GLOBALS['user_id'], $GLOBALS['notShowAdsUsers']
) ){

//You Adsense generated code here
$GLOBALS['adsense'] = <<<out

<script type="text/javascript"><!--
google_ad_client = "pub-XXXXXXXXXXXXXXXX";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "E9EFF4";
google_color_bg = "E9EFF4";
google_color_link = "006699";
google_color_text = "000000";
google_color_url = "006699";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

out;

}

Author Anonymous
Guest
#7 | Posted: 8 Jan 2007 11:29 
Thank you!

Author Anonymous
Guest
#8 | Posted: 9 Jan 2007 11:58 
Does not show on post pages when using {$adBlock} or {$adsense}. I am using this in main_header.html.

Also, I notice if I have code, which would then contain two parseMessage written in bb_plugins, when I remove the one from the code above, it allows me to display the forum, but does not display the ads. When I have two parsemessage in the code, it shows a blank screen.

My question is how do you write the above code so the parsemessage is not part of it, and which variable {$adBlock} or {$adsense} do I use because neither one will display the ads.

Author Paul
Lead Developer 
#9 | Posted: 10 Jan 2007 04:21 
I didn't get your idea... the code I've provided above is about displaying ads only in the message thread (since parseMessage() function is designed for parsing each message).

Of course there can not be 2 functions with identical names. Blank screen most probably means PHP reports a critical error, only you don't see it because of the settings specified in php.ini.

If you want to use constant ads at the top of forums for example, just use the code I provided first. So the answer to your question How do you put these two code together? would be: just paste provided code in bb_plugins.php, replacing Put your ad html here but the Google adsense, that's all.

Author Anonymous
Guest
#10 | Posted: 10 Jan 2007 20:33 
Okay, let me start over, I appreciate your patience with my typing.

I wanted to show ads in both, the main_header.html and the main_footer.html. I also wanted to show ads in the threads, such as after post #1 and post #9 as described in the code above.

I wanted this to be blocked for certain members so they don't have to see ads, just as the code above shows $notShowAdsUsers=array(1,2,3);

When I try the codes above, I am only able to either put ads in the header/footer OR within the messages. Not both. It turns into a white page when refreshing.

I would like a code written so that it doesn't interfere with the first parsemessage. The parsemessage I have written in shows something about fileuploads and resizing pictures within the code.

Author Paul
Lead Developer 
#11 | Posted: 11 Jan 2007 03:15 
parseMessage should be concatenated for all cases, as it can be only the one.

I'm suspecting this is a question of our custom paid job; however, in general the code for your purpose would be just like I've posted already...

$notShowAdsUsers=array(1,2,3);
//specify IDs of users in array above

if($user_id!=0 and !in_array($user_id, $notShowAdsUsers)) {
//by this condition, we will display ads for every registered member, except not for defined IDs above
$adBlock=<<<out
Put your ad html here
out;
}
else $adBlock='';

function parseMessage(){

//Use $GLOBALS['anchor'] for determining the anchor value
$GLOBALS['adsense']='';

if ( ($GLOBALS['anchor']==1 or $GLOBALS['anchor']==9) and $GLOBALS['user_id']!=0 and !in_array($GLOBALS['user_id'], $GLOBALS['notShowAdsUsers']
) ){

//You Adsense generated code here
$GLOBALS['adsense'] = <<<out

<script type="text/javascript"><!--
google_ad_client = "pub-XXXXXXXXXXXXXXXX";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "E9EFF4";
google_color_bg = "E9EFF4";
google_color_link = "006699";
google_color_text = "000000";
google_color_url = "006699";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

out;

}

Afterall you will need to paste {$adBlock} in main_header.html and/or main_footer.html and paste {$adsense} in main_posts_cell.html

This is all I can help you with.

Author Sergeusz
Partaker
#12 | Posted: 8 May 2008 13:55 
What about not showing urls in threads for guests? Instead of url they see something like "Register to see links". Could be this implement in minibb?

Author Paul
Lead Developer 
#13 | Posted: 9 May 2008 03:06 
This could be implemented using parseMessage() function (so it checks for $GLOBALS['user_id'] and if it is equal to 0, uses regular expression to remove all hyper links or replace them to some text).

Author Sergeusz
Partaker
#14 | Posted: 9 May 2008 13:34 
if($GLOBALS['user_id']==0) {
What I need to place here?
}

Author Paul
Lead Developer 
#15 | Posted: 12 May 2008 03:39 
It could be similar to the below code, but it really depends on what kind of links would you like to cut off (and in general, what for it would be needed):

if($GLOBALS['user_id']==0) {
$GLOBALS['posterText']=preg_replace("#<a href=\"(.+?)>(.*?)</a>#is", '[Available to Members only]', $GLOBALS['posterText']);
}

Page  Page 1 of 2:  1  2  Next » 
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 How To Show/Block specific content (Ads) for guests/members or certain users
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑