How to write the logic.
There are four part in include/config.php
(A) Prefereces Part
There are three parameters in the current version.
read (1) and (2).
// preferences
$auto_belong_groups = array( XOOPS_GROUP_USERS ) ; // default (2)
$allow_blank_email = false ;
$allow_blank_vpass = false ;
$extra_fields = array(
'sex' => array(
'initval' => -1 ,
'options' => array( 0 => 'male' , 1 => 'female' ) ,
) ,
'birth' => array(
'initval' => '1950-01-01' ,
) ,
) ;
if( empty( $minihaku_uid4whr ) ) {
// for registering
foreach( $extra_fields as $key => $attribs ) {
$allowed_requests[$key] = $attribs['initval'] ;
}
} else {
// for editing or minihaku's smarty plugin
// a query for getting values in extra fields
$db =& Database::getInstance() ;
list( $allowed_requests['sex'] , $allowed_requests['birth'] ) = $db->fetchRow( $db->query( "SELECT sex,birth FROM ".$db->prefix("users")." WHERE uid=$minihaku_uid4whr" ) ) ;
// It is important to filter intval() here
$allowed_requests['sex'] = intval( $allowed_requests['sex'] ) ;
// prepare string for display in minihaku's smarty plugin
$fields4html['sex'] = $extra_fields['sex']['options'][ $allowed_requests['sex'] ] ;
$fields4html['birth'] = str_replace( '-' , '/' , $allowed_requests['birth'] ) ;
}
if( isset( $_POST['sex'] ) ) {
if( $_POST['sex'] < 0 || $_POST['sex'] > 1 ) {
die( "invalid sex value" ) ;
}
}
if( ! empty( $_POST['Date_Year'] ) ) {
$_POST['birth'] = intval( $_POST['Date_Year'] ) . '-' . intval( $_POST['Date_Month'] ) . '-' . intval( $_POST['Date_Day'] ) ;
}