PDA

View Full Version : Setting a plugin to activate at a certain post count


MTGDarkness
03-09-2009, 05:06 AM
In userdata presave:

if ($this->fetch_field('userid') == 36)
{
//if($this->fetch_field('posts?') == 666)
$this->do_unset('posts');
//}
}

Not sure what to do with the posts thing. I imagine it's very similar syntax.

In case anyone wonders, I'm trying to be very mean to a certain poster who is bragging all the time about being about to hit 3000 posts.

--------------- Added 1236662338 at 1236662338 ---------------

Bump?

MTGDarkness
03-10-2009, 01:37 PM
Help?

Lynne
03-10-2009, 02:03 PM
Exactly what are you trying to do? Make it so if he makes a post then his post count is not increased?

MTGDarkness
03-10-2009, 02:09 PM
When he reaches a certain post count, it stops his post count.

Lynne
03-10-2009, 02:59 PM
Instead of doing an unset (I'm not sure how you would do that), why not just set it to the postcount you want it to stay at?
if ($this->fetch_field('userid') == 36)
{
if($this->fetch_field('posts') >= 666)
{
$this->set('posts', 666);
}
}

Although, looking more into it there, it doesn't look like the posts are actually saved there. It looks like it is passed back in the $userinfo array. So, I think you may want to do something more along these lines (again, not tested, play with it on a test site):
if ($this->fetch_field('userid') == 36)
{
if($this->fetch_field('posts') >= 666)
{
$posts = 666;
$userinfo = array(
'userid' => $userid, // we need an userid for is_member_of's cache routine
'posts' => $posts
);
}
}

MTGDarkness
03-10-2009, 03:10 PM
do_unset('posts') was the snippet you gave to me when I asked about this on a slightly less advanced level. But this should work. Thanks. :)

Lynne
03-10-2009, 03:27 PM
I gave it to you? Hehe. I'm not fully caffeinated yet... that is my excuse and I'm sticking to it!

MTGDarkness
03-10-2009, 05:36 PM
I take it back. You didn't directly give it to me, you just put it up in some thread. :p So technically, it comes from you.

Lynne
03-10-2009, 05:41 PM
Hmm, OK, if you say so. :)

So, did you get this to work? You should post what you did so if someone else wants to do this to a user, they can get the code here (would be fun to do something with it for April Fools).

MTGDarkness
03-10-2009, 05:43 PM
I'm not sure if it works or not, it hasn't triggered yet.
http://forums.mtgdarkness.com/test-area-f65/itt-we-plan-my-3000th-post-t2126/
I'm using it on the OP of that thread, set to 2999. https://vborg.vbsupport.ru/external/2009/03/102.jpg

Lynne
03-10-2009, 08:10 PM
Do you have a test site? Or a test account? If you don't have a test site, use a test account and change the id in your plugin to the id of your test account and change the post count for your test account to just trigger it. You should be able to test it that way.