I have a channel form where I need to verify they know the league password before they can submit to be added to the “users” channel.
What’s the best way to hook into this? I’m gathering I’ll need to tie into the channel_form_submit_entry_start($channel_form_obj) but I’ve never used hooks so wondering if someone could give me a quick example. The docs aren’t very in depth for hooks.
Here’s my template flow:
{exp:channel:entries channel="leagues" require_entry="yes"}
{exp:channel:form
channel="users"
include_assets="no"
error_handling="inline"
return="leagues/join-league-success/URL_TITLE"
}
// display league settings from entry they want to join which has a league pass they need to know
<input type="password" name="verifyPassword" id="verifyPassword" placeholder="Enter League Password..." required>
I think there are a number of ways you could go at it- and I wouldn’t nest the form inside an entry tag.
I’d actually consider making the password a custom field and then it’s just regular validation. Of course, that would be the case in the CP as well, but if that’s not problematic, that’s what I’d lean toward doing. And you can look at any of the fieldtypes in system/ee/EllisLab/Addons/ for good examples. That way validation of your password would work just like validation of any of the other fields.
But a hook is also a good way to go at it, especially if you did NOT want it to act like regular field validation. Take a look in channel_form/Channel_form_lib.php- find the hook. You can do just about anything you want it the password doesn’t validate. From stopping processing and returning a system message to throwing an error.
I think the option you want to go with will just depend on how you want the validation to work.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.