Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2011, 10:25 PM
spillage spillage is offline
 
Join Date: Feb 2009
Location: S. Florida
Posts: 165
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 12-13-2011, 01:13 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 09-20-2012, 05:16 AM
Edgespeeder06 Edgespeeder06 is offline
 
Join Date: Nov 2009
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 09-20-2012, 10:14 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 09-20-2012, 11:15 AM
Edgespeeder06 Edgespeeder06 is offline
 
Join Date: Nov 2009
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 09-20-2012, 11:42 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Edgespeeder06 View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03864 seconds
  • Memory Usage 2,206KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete