The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Infraction Hook
Hello,
It's me again - I was wondering if anyone could tell me which hook to latch my plugin onto if I wanted to modify a column within the users table. I have tried the hooks 'infractiondata_postsave, infractiondata_presave, and memberinfraction_complete". Either I have the wrong hook, or something in my code is wrong (which is probably the case) PHP Code:
|
Благодарность от: | ||
MarkFL |
#2
|
||||
|
||||
Okay, the first thing is, in a plugin you don't want to include the PHP tags. If your code is in an external file called by a plugin, then you do need the tags.
The hook location "infractiondata_postsave" is a good one (assuming you want this code to execute after the infraction is given), and you'll need to make the $userinfo array global to access it. This array will contain information regarding the user receiving the infraction. You first query looks like it needs some tweaking, but please let me know exactly what you want to accomplish with this code, and I will try to point you in the right direction. |
Благодарность от: | ||
Chris.08i |
#3
|
|||
|
|||
Quote:
The base amount is 150 points, but each active infraction point (ipoints in users table as far as I know) will apply a 2.5x multiplier. For example, someone with 4 infraction points will receive 1500 points deduction from their reputation column. I hope that makes sense. |
#4
|
||||
|
||||
Quote:
PHP Code:
|
#5
|
|||
|
|||
Quote:
What if ipoints = 0? I still want to deduct 150 from their reputation. |
#6
|
||||
|
||||
Quote:
PHP Code:
|
#7
|
|||
|
|||
Quote:
I was going to use if statements to create the effect I needed, turns out I don't need to! Thanks so much for your help Mark, definitely learned a lot these couple days. Edit: I just tried it - I'm getting a Server 500 error when I try infract someone. Any ideas? Edit #2: So I globalised $vbulletin as well and it started running the code properly. However it isn't properly deducting from the table. Edit #3: I got it to deduct! It turns out we were missing an 'END' to the case which cause an MySQL syntax error. However it now seems like it's going through both cases and deducting a total of 525 every time, no matter what! Not sure why the case rules aren't working! Edit #4: Okay - I got fed up so I ended up going with this. However, this code for some reason deducts double what I calculate it should do. For example, those with 0 ipoints, gets deducted 300 instead of 150, and those with 1 ipoint get deducted 750 instead of 375. PHP Code:
|
#8
|
||||
|
||||
This plugin works correctly on my local dev site:
Product: vBulletin Hook Location: infractiondata_postsave Title: Deduct Rep When Infracting Execution Order: 5 Plugin PHP Code: PHP Code:
|
#9
|
|||
|
|||
I had an adaptation of mine that I have been using for the past couple days that have been working for me.
I have changed over to your code as it's much neater! Thank you again Mark for your time and help! I was wondering if it was possible to only trigger the above deduction when an actual point is issued, and no deduction for warnings? |
#10
|
||||
|
||||
Quote:
The code I posted does exactly the opposite of that...it uses $userinfo['ipoints'] which does not include the points currently being given, but rather the number of points accumulated by the user before the current infraction. edit: Try using the hook location "infraction_update_complete", and at that hook, the points for the current infraction is in $vbulletin->GPC['points']. Then you can base the rep deduction on that and update the user table. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|