Results 1 to 4 of 4

Thread: Defaulting the Registration Module Country field

  1. #1
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Defaulting the Registration Module Country field

    I have two Member Groups that can be signed up to.
    In one of them ONLY (Schoolmembers) I would like the Registration Forms "Country" select-menu to default to New Zealand.
    Any idea how I can go about this?
    Thanking you

  2. #2
    User
    Join Date
    06-19-09.
    Posts
    89

    Default Re: Defaulting the Registration Module Country field

    Hi Ramjet,

    Did you get this taken care of? I'm looking to do the same thing for one of our registration forms but I want it to default to the United States.

    Justin

  3. #3
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Defaulting the Registration Module Country field

    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';
    }

  4. #4
    User
    Join Date
    06-19-09.
    Posts
    89

    Default Re: Defaulting the Registration Module Country field

    Thanks ramjet, that worked great!

    For anyone else:
    I actually didn't need the extra code ramjet used for the two Member Groups. I wanted to make all my registration forms default to the United States.

    To do this, you can put this one line in your dcaconfig file:

    $GLOBALS['TL_DCA']['tl_member']['fields']['country']['default'] = 'us';

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •