vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Members only widget? (https://vborg.vbsupport.ru/showthread.php?t=275393)

spillage 12-12-2011 10:25 PM

Members only widget?
 
I've searched, seen a few questions that touch on the subject, but no answers.

How does one code a widget to be visible to members only?

I have an HTML widget, but want it to be visible to members only... I take it this will now have to be PHP.

Assistance would be greatly appreciated.

kh99 12-13-2011 01:13 AM

If you want a widget where the html changes depending on whether or not the user is a guest, then you could create a php widget with code like this:

Code:

if (vB::$vbulletin->userinfo['userid'] == 0)
$output = "This is some html for guests<br />\n";
else
$output = "This is some html for members<br />\n";


and set the cache time to 0. If you want the entire widget to disappear for guests then you could change the "Template Name" field to a custom template, copy the vbcms_widget_execphp_page template contents to your custom template, and surround it with a conditional that checks for $bbuserinfo[userid] != 0.

Edgespeeder06 09-20-2012 05:16 AM

Hi sorry for reviving an old thread but I can't get this to work:

Code:

if (vB::$vbulletin->userinfo['userid'] == 0)
$output = "<br />\n";
else
$output = "Advertise with NJStangers Today!<br />\n";

I try putting my ad code from google in the first box and it doesn't seem to work, I get an error and nothing shows up logged in or logged out.

kh99 09-20-2012 10:14 AM

I tried the code you posted and it works for me. The message gets displayed to members only, and for guests the widget is blank. If you want to post the exact code you tried we can look at that.

Edit: also, I might have been wrong when I said that you need to set the cache time to 0 - I think the widget is cached for each user. So you should try setting the cache time to 1 or more and see if that works.

Edgespeeder06 09-20-2012 11:15 AM

Thank you, the error message comes when I add a google adsense ad code into there. Is that not possible into php? How do I get around it so I can put an ad on the widget page visible to guest only?

Maybe something down the road for Vbulletin to build into their Ad management tool since they have it for the CMS yet. Thank you

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

Solution here for anyone who needs it:
https://vborg.vbsupport.ru/showpost....52&postcount=2

Thanks again

kh99 09-20-2012 11:42 AM

Quote:

Originally Posted by Edgespeeder06 (Post 2366963)
Thank you, the error message comes when I add a google adsense ad code into there. Is that not possible into php?

I'd have to see exactly what you're trying to do. It should be possible to do almost anything you want using a php widget, so it could just be a syntax error that can be easily fixed.


All times are GMT. The time now is 11:00 PM.

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.00970 seconds
  • Memory Usage 1,725KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete