vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   hide a block from membergroup (https://vborg.vbsupport.ru/showthread.php?t=289090)

Skivey 10-15-2012 01:55 PM

hide a block from membergroup
 
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 [DATE]1350419872[/DATE] at [TIME]1350419872[/TIME] ---------------

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:
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 [DATE]1350499765[/DATE] at [TIME]1350499765[/TIME] ---------------

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:

PHP Code:

if (is_member_of(vB::$vbulletin->userinfo1)) {
$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

PHP Code:

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 [DATE]1350506546[/DATE] at [TIME]1350506546[/TIME] ---------------

dunno why there are +'s there.. tey are spaces normally

--------------- Added [DATE]1350510449[/DATE] at [TIME]1350510449[/TIME] ---------------

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.

HTML Code:

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;



All times are GMT. The time now is 05:30 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01257 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete