The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Hack for Maximum Post Count
Hello, all. We have a pretty complex aMember setup and can't really take full advantage of the VB Promotions system to create a usergroup for this specific need.
We have a newbie's corner that is designed to be a place for new members to congregate and discuss their experiences. We want to limit it to people with 150 or fewer posts. We've tried hacking the Advanced Permissions Based on Post Count mod, but it's got a lot more to it than what we need. We found a different plugin that had much fewer options, rewrote it to look for post counts and exclude the admins and moderators, but we just can't get it to work correctly. Any thoughts on what we might do differently? Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <product productid="newbie_corner" active="1"> <title>Newbie Corner Hack.</title> <description>This is a custom plugin to set the newbie corner board to be viewable only by those with 150 or fewer posts.</description> <version>1</version> <url>http://www.somesite.com</url> <versioncheckurl /> <dependencies> </dependencies> <codes> </codes> <templates> </templates> <stylevardfns> </stylevardfns> <stylevars> </stylevars> <plugins> <plugin active="1" executionorder="5"> <title>Minimum number of posts to view forum.</title> <hookname>forumdisplay_start</hookname> <phpcode><![CDATA[global $vbulletin, $foruminfo; $newbieid = '814'; $adminid = array(6,14); $maxposts = 150; if(in_array($vbulletin->$foruminfo['forumid'], $newbieid)) { if (!is_member_of($vbulletin->userinfo, $adminid)) { if ($vbulletin->userinfo['posts'] < $maxposts) { standard_error(fetch_error('numposts_message', $vbulletin->userinfo['username'], $vbulletin->userinfo['posts'])); } } } }]]></phpcode> </plugin> </plugins> <phrases> <phrasetype name="Error Messages" fieldname="error"> <phrase name="numposts_message"><![CDATA[An error has occurred {1}! You must have 150 or fewer posts in order view this forum. Your current post count is {3}.]]></phrase> </phrasetype> </phrases> <helptopics> </helptopics> <cronentries> </cronentries> <faqentries> </faqentries> </product> |
#2
|
|||
|
|||
In this line:
Code:
if(in_array($vbulletin->$foruminfo['forumid'], $newbieid)) you should remove the $vbulletin and just use $foruminfo['forumid'] (but I'm not sure if that's the only problem). |
#3
|
|||
|
|||
That removed the 500 error we were receiving, but when testing it with a user with more than 150 posts who is not in an Administrator or Moderator, it still allows them to view the forum.
Am I using the wrong hook or is the way I'm grabbing their group ID or post count incorrect? |
#4
|
|||
|
|||
It could this:
Code:
if(in_array($vbulletin->$foruminfo['forumid'], $newbieid)) because $newbieid isn't an array (you probably just want to use ==). |
#5
|
|||
|
|||
OK, I tried that, but with no luck. I also removed the code to check and see if you were in the admin array and the same results. This narrows it down to not calling the forum ID, not counting the posts or not using my hooks appropriately.
Any other ideas? Here's my latest code: Code:
<plugins> <plugin active="1" executionorder="5"> <title>Minimum number of posts to post links.</title> <hookname>forumdisplay_start</hookname> <phpcode><![CDATA[global $vbulletin, $foruminfo; $newbieid = '814'; $maxposts = 150; if($foruminfo['forumid'] == $newbieid) { if ($vbulletin->userinfo['posts'] > $maxposts) { standard_error(fetch_error('numposts_message', $vbulletin->userinfo['username'], $vbulletin->userinfo['posts'])); } } }]]></phpcode> </plugin> </plugins> <phrases> <phrasetype name="Error Messages" fieldname="error"> <phrase name="numposts_message"><![CDATA[An error has occurred {1}! You must have 150 or fewer posts in order view this forum. Your current post count is {3}.]]></phrase> </phrasetype> </phrases> |
#6
|
|||
|
|||
Oh...you have an extra closing } in there - take off one of the 3 at the end. It seems to work OK - where you're getting the forumid and posts look right.
|
#7
|
||||
|
||||
If you want you can use my mod here. You can set the post count needed to enter a forum on a forum per forum basis.
https://vborg.vbsupport.ru/showthread.php?t=249977 |
#9
|
|||
|
|||
Hey, @borbole. I have a question for you about your mod. As you know I modified it to look for a maximum post count rather than a minimum post count and it works perfectly. But I am now noticing that people can still see posts from this "limited access" forum when they click on the "New Posts" link.
I want to add some code to the mod that prevents the user from seeing the posts from that forum if they don't meet the number of posts criteria but I'm not sure which hookname to tap into. I'd be glad to pay for the work, or if you wouldn't mind telling me which hookname I should be looking at to target the New Posts section, I can take a stab at it myself and share it here once I get it working. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|