Difference between revisions of "How to add special validation for some fields on signup form"

From aMember Pro Documentation
Jump to: navigation, search
Line 1: Line 1:
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>
<?php
 
 
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, 'siteValidateForm');
 
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, 'siteValidateForm');
  

Revision as of 03:08, 3 November 2015

Add this code to site.php file:

Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, 'siteValidateForm');
 
function siteValidateForm(Am_Event_ValidateSavedForm $event)
{
    $form = $event->getForm();
    $vars = $form->getValue();
    if (isset($vars['email']) && ($vars['email'] != 'test')) { // perform some validation
        $event->addError('Some Error Accured!');
    }
}