PDA

View Full Version : Hack for Maximum Post Count


clickinmoms
07-16-2012, 10:55 PM
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?


<?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>

kh99
07-16-2012, 11:05 PM
In this line:

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).

clickinmoms
07-16-2012, 11:29 PM
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?

kh99
07-17-2012, 12:12 AM
It could this:

if(in_array($vbulletin->$foruminfo['forumid'], $newbieid))


because $newbieid isn't an array (you probably just want to use ==).

clickinmoms
07-17-2012, 05:55 AM
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:

<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>

kh99
07-17-2012, 10:41 AM
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.

borbole
07-17-2012, 10:46 AM
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

clickinmoms
07-17-2012, 01:34 PM
Thanks to both of you. I went ahead and modified your code @borbole to meet our needs. Worked like a charm!

clickinmoms
08-16-2012, 02:17 PM
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.