View Full Version : hide a block from membergroup
Skivey
10-15-2012, 01:55 PM
I have an "advert" block that I want to hide from paid members. Is there a simple way to do this?
http://forum.rsclassics360.co.uk/forum.php
Thanks
Matt
Skivey
10-16-2012, 06:55 PM
anyone?! :(
--------------- Added 1350419872 at 1350419872 ---------------
i tried doing this within the block.... dont work...
<if condition="$post['usergroupid'] != 24">
GOOGLE ADSENSE HERE
</if>
qpurser
10-17-2012, 01:43 PM
I am not a pro in coding but did something similar. Not exactly the same what you are looking for but it might help to figure it out.
I didn't wanted to hide a block but display a message instead in that block to animate the unregistered/visitors (usergroupid 1) to register.
my code:
<vb:if condition="is_member_of($bbuserinfo, 1)">
Only Registered/Logged in users can view this section
<vb:else />
**** add here the contents you want to display and remember to add "</vb:if>" at the end of the contens you display****
by doing this everybody not belonging to usergroupid 1 will see the contents of the block
Skivey
10-17-2012, 03:26 PM
hmm that dont seem to work, is this in HTML, or PHP?
Mine is in HTML and its a adwords script within... i dunno its quite frustrating.
Thanks for the help
Lynne
10-17-2012, 03:55 PM
What *exactly* did you try and where, Skivey? We need the exact code and the template name.
Skivey
10-17-2012, 05:22 PM
hi lynne
Im using my google adsense code and putting it in the HTML block
I only want 'registered' members to see this block as my gold members have paid to remove adverts. Ive managed to do this for all of my forum except this.
I used the above code and put the google code in between it
If there isnt an easy way to do this, then ill just have to remove the block and put more adverts elsewhere... just would be good for the way the forum is laid out.
http://forum.rsclassics360.co.uk - its the advert on the left hand side block 'Advert'
Regards
Matt
--------------- Added 1350499765 at 1350499765 ---------------
oh and template is darkvision :)
Its quite editable
I was hoping each block may have an 'id' so that i can put something in the blocks template?
Thanks
Matt
Lynne
10-17-2012, 06:00 PM
So is this an html block? Or a PHP block or what? You cannot use template code in a block - it is for templates only. If you want block code to not show to a usergroup, you would need to use a PHP block and use PHP code like:
if (is_member_of(vB::$vbulletin->userinfo, 1)) {
$my_output = "html code here";
} else {
$my_output = "other html code here";
}
return $my_output;
Skivey
10-17-2012, 07:41 PM
So I have this in a PHP block but its showing not even a block for any membergroup. The idea is it only shows to normal registered members.
The code I put in was in a normal HTML block, but I understand it has to be in a php block now.
Here is what I tried... but nothing yet
if+(is_member_of(vB::$vbulletin->userinfo,+2))+{
$my_output+=+"<script type="text/javascript"><!--
google_ad_client = "ca-pub-2764312150803413";
/* sideblock */
google_ad_slot = "1598615235";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>";
}+else+{
$my_output+=+"";
}
return+$my_output;
--------------- Added 1350506546 at 1350506546 ---------------
dunno why there are +'s there.. tey are spaces normally
--------------- Added 1350510449 at 1350510449 ---------------
its the speech brackets isnt it... think it messes it up....
Lynne
10-17-2012, 09:16 PM
Use single quotes around the $my_output variable stuff (leave the double-quotes for the stuff inside).
Skivey
10-18-2012, 05:25 AM
its bizarre, its still showing nothing.
Block is enabled, and the script is below.
Im thinking im gonna put the adverts somewhere else.
if+(is_member_of(vB::$vbulletin->userinfo,+2))+{
$my_output+=+'<script type="text/javascript"><!--
google_ad_client = "ca-pub-2764312150803413";
/* sideblock */
google_ad_slot = "1598615235";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
}+else+{
$my_output+=+'GOLD MEMBER';
}
return+$my_output;
Lynne
10-18-2012, 03:00 PM
Nothing shows up? Not even the title of the block? It is working fine on my test site (only I removed the + in the code above). (Although, all I see if a black box.)
141803
141802
Skivey
10-19-2012, 06:49 AM
Nothing shows up? Not even the title of the block? It is working fine on my test site (only I removed the + in the code above). (Although, all I see if a black box.)
141803
141802
no it was blank!
Ill try again with a new block
--------------- Added 1350634342 at 1350634342 ---------------
it seemed to be the spaces ' '
Deleting all of them and it all works! woohoo!
Thanks for all you help, very much appreciated!
Matt
Dan321
08-04-2013, 06:48 AM
whats the correct code ?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.