How to add special validation for some fields on signup form

From aMember Pro Documentation
Revision as of 02:41, 10 January 2013 by Caesar (Talk | contribs)

Jump to: navigation, search

Create /amember/application/configs/site.php with this code:

<?php
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, 'siteValidateForm');
 
function siteValidateForm(Am_Event_ValidateSavedForm $event)
{
    $form = $event->getForm();
    $vars = $form->getValue();
    if ($vars['email'] != 'test') {
        /* @var $email HTML_QuickForm2_Element */
        list($email, ) = $form->getElementsByName('email');
        $email->setError('Some Error Accured!');
    }
}