The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
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. |
#5
|
|||
|
|||
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 } |
#6
|
|||
|
|||
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).
|
#7
|
|||
|
|||
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> Its ok, worked it out now! |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|