![]() |
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 |
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) I'm not sure if you even need to check both, it may be that posts is always 0 or undefined for guests. |
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? |
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. |
How about something like this?
Code:
if ($vbulletin->userinfo['userid'] != 0 AND $vbulletin->userinfo['posts'] > 1000 and $vbulletin->userinfo['posts'] < 2000) |
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).
|
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"> Its ok, worked it out now! |
All times are GMT. The time now is 11:16 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|