HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
How do I extend the application controllers with my own methods?
dave_stewart
New
As I want to make an addition to the registration process.
I was planning on doing this by extending a couple of core files...
* applications\dashboard\views\entry\registerapproval.php
* applications\dashboard\controllers\class.entrycontroller.php
... in a custom theme:
* themes\[theme]\views\entry\registerapproval.php
* themes\[theme]\controllers\class.entrycontroller.php
The view file is great. It loads in, and I can see my changes.
But I don't know how to handle the controller, including:
* What folder to put it in
* The controller declaration (ie CustomEntryController X extends EntryController)
* Anything else I haven't mentioned here
* Whether this is even possible with this approach
My plan was to overload RegisterApproval() and check that the DiscoveryText was in fact the answer to a question I was going to ask in the view.
It's not a particularly MVC approach (I see there are rules that could be set in the model) but I don't know Garden / Vanilla well enough yet. I'm happy to try anything else as well (hooks/events/Machine Elves) as I prefer to do things properly.
Cheers,
Dave
I was planning on doing this by extending a couple of core files...
* applications\dashboard\views\entry\registerapproval.php
* applications\dashboard\controllers\class.entrycontroller.php
... in a custom theme:
* themes\[theme]\views\entry\registerapproval.php
* themes\[theme]\controllers\class.entrycontroller.php
The view file is great. It loads in, and I can see my changes.
But I don't know how to handle the controller, including:
* What folder to put it in
* The controller declaration (ie CustomEntryController X extends EntryController)
* Anything else I haven't mentioned here
* Whether this is even possible with this approach
My plan was to overload RegisterApproval() and check that the DiscoveryText was in fact the answer to a question I was going to ask in the view.
It's not a particularly MVC approach (I see there are rules that could be set in the model) but I don't know Garden / Vanilla well enough yet. I'm happy to try anything else as well (hooks/events/Machine Elves) as I prefer to do things properly.
Cheers,
Dave
Tagged:
0
Best Answer
-
Todd Vanilla StaffWe actually have a way to block registrations with plugins specifically. Here's the code for your event handler:
public function UserModel_BeforeRegister_Handler($Sender, $Args) {
To answer your specific question, unfortunately you can't override the RegisterApproval method because it is not called through the dispatcher. You could override the Register method which is what you are going to anyway. You do this with the following event handler:
$User = $Args['User']; // Check this user...
...
$Args['Valid'] = FALSE; // false blocks the registration
}public function EntryController_Register_Override($Sender, $Args) { ... }
0
Answers
In which classes is the above code supposed to reside?
There was an error rendering this rich post.
Ta