I did it with a createNewUser hook in the module I wrote
hook registered in the module config
Code:
//HOOK TO Fill in schoolsearch userid field with tl_member id on new signup, and fill COMPULSORY country field with "new zealand" On Signup
$GLOBALS['TL_HOOKS']['createNewUser'][] = array('SchoolRegHook', 'createNewUser');
the hook (SchoolRegHook.php) in the module root
Code:
class SchoolRegHook extends Backend
{
//HOOK TO Fill in schoolsearch userid field with tl_member id on new signup, also to automatically fill members country with nz in member
public function createNewUser($intId, $arrData)
{
//check the nzqaid exists in tl_school_schools
$checknzqaid = $this->Database->prepare("SELECT nzqaid from tl_school_schools WHERE nzqaid=?")
->limit(1)
->execute($arrData['schoolnzqaid']);
//if the nzqaid exists in the database
if($checknzqaid->numRows > 0)
{
// update tl_school_schools userid with the value of member id number
//set multiplelocations_allow to '', which will prevent new signup of 'child' school using 'parents' Active Link
$this->Database->prepare("UPDATE tl_school_schools SET multiplelocations_allow = '',userid=? WHERE nzqaid=?")
->limit(1)
->execute($intId,$arrData['schoolnzqaid']);
//automatically fill members country with nz in member
$this->Database->prepare("UPDATE tl_member SET country='nz' WHERE id=?")
->limit(1)
->execute($intId);
}
}
}
but you may be able to also do it within an if in system/config/dcaconfig.php (untested)
Code:
if($objGroup->name == 'School Members')
{
//$GLOBALS['TL_DCA']['tl_member']['fields']['country']['eval']['mandatory'] = true;
$GLOBALS['TL_DCA']['tl_member']['fields']['country']['default'] = 'us';
}
Bookmarks