Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Making a custom error if a condition is met before submitting a thread?
Chizbang
New
Hi!
I am totally new to Vanilla Forums and im moving from MyBB. I want to make a plugin (Which I have half done in MyBB) which allows you to set a bounty for your question which gets taken out your wallet (which is something else il be developing for it). What I need to do is, make sure the user has enough credits to set a bounty. So before the thread is submitted, I need to do a check to see if the user has enough credits to set that much bounty, if so, continue. If not, send the user back and tell them to set a lower bounty.
Im capible of doing all of that in PHP, I just need to know what I would need to do to stop a thread from being submitted.
Any ideas on what hook id need to use and how id stop the thread submission?
0
Comments
Welcome to the community!
You need to hook into the discussion model and run your validation code before discussion save.
Something like this will get you started:
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
If you have code that would make up a plugin for MyBB, you do not benefit from Garden, the framework that Vanilla is based on. I do not know how you are storing the credit info but if you have created a simple table UserID|CreditAmount you could benefit from the framework a lot.
Simply add something like that to your code and you have the credit amount always at hand, because that info will be automagically available with the user object as $User->Credit:
But maybe you already did it that way or your plugin needs a one-to-many relation between user and credit, then simply forget about it
Nevertheless I would advice you to look at plugins that try to achieve similar things you want to achieve and learn from them. Maybe Karma is a good plugin to look at
Or
@Chizbang I take you are going to escrow the funds on save, otherwise checking whether there is funds coun be moot. Especially if someone tries to break it.
You need a transactional system strictly speaking. So a bounty is held until that one discussion is posted, and no other discussion can be posted until either the transaction is canceled, or it is placed and the funds secure.
Definitely worth reading up on transactional systems.
Another way is to 'purchase' the bounty before hand. That is what I have done with purchase anonymous posts. It is a type of discussion that either available or not.
grep is your friend.
Sounds like a funny feature! Which plugin offers something like that?
Thanks both! That should work swell.
Il update you on how I get along.
@x00 good call on
$Sender->Validation->AddValidationResult();
Looks like DiscussionPolls needs some polishing.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.