Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2012, 08:30 PM
Jon12345 Jon12345 is offline
 
Join Date: Nov 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Code conditional on member post count

I want to run some code but only if a member has >X number of posts and is logged in. Is that possible?

Thanks,

Jon
Reply With Quote
  #2  
Old 04-12-2012, 08:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What do you mean by "run some code"? Do you want to check for that condition in a plugin? I think it would be:

Code:
if ($vbulletin->userinfo['userid'] != 0 AND $vbulletin->userinfo['posts'] > X)
{
  // run code
}

I'm not sure if you even need to check both, it may be that posts is always 0 or undefined for guests.
Reply With Quote
  #3  
Old 04-12-2012, 08:53 PM
Jon12345 Jon12345 is offline
 
Join Date: Nov 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Essentially, I want it for the thread view so that members who have 1,000 posts or more see less adds. I will try that code thanks. I knew there must be some way to do it but had no idea how.

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

I've just had a brainwave.

Is it possible to have some multiconditional stuff, like a Select Case used in some programming languages?

i.e. if over 5,000 posts show no ads, if over 1,000 show 1 ad, if under 1,000 show 2 ads?
Reply With Quote
  #4  
Old 04-12-2012, 09:46 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, in a plugin you could use switch: http://us2.php.net/manual/en/control...res.switch.php.

Another way would be to use usergroups - you can add "promotions" that will change a user's group (or add a secondary group) based on post count, and you could then decide on ads based on group. Don't know if that would be easier or not, but it's there.
Reply With Quote
  #5  
Old 04-12-2012, 09:51 PM
Jon12345 Jon12345 is offline
 
Join Date: Nov 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How about something like this?

Code:
if ($vbulletin->userinfo['userid'] != 0 AND $vbulletin->userinfo['posts'] > 1000 and $vbulletin->userinfo['posts'] < 2000)
{
  // run code A
}
if ($vbulletin->userinfo['userid'] != 0 AND $vbulletin->userinfo['posts'] >= 2000 and $vbulletin->userinfo['posts']<5000)
{
  // run code B
}
Would that work? Are you allowed to use >= next to one another?
Reply With Quote
  #6  
Old 04-12-2012, 09:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That looks OK to me. I suppose you might want "else if" for all but the first, that way you could have an "else" at the end if you wanted (although I suppose a last > test would do the same thing).
Reply With Quote
  #7  
Old 04-12-2012, 10:05 PM
Jon12345 Jon12345 is offline
 
Join Date: Nov 2002
Posts: 127
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great, I will try the above code then. Thanks for the guidance.

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

I have just realised that I think the above code is if I am doing a plugin. But i want to just edit the template. To translate this into something that would work in a template, would my code attempt below be a fair translation?

Code:
<if condition="$vbulletin->userinfo['posts'] > 1000 and $vbulletin->userinfo['posts'] < 2000">

  // run code A

</if>
--------------- Added [DATE]1334329256[/DATE] at [TIME]1334329256[/TIME] ---------------

Its ok, worked it out now!
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 08:54 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.04982 seconds
  • Memory Usage 2,214KB
  • 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
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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