Auto register plugin has nothing to do with this one.This plugin insert into oc_t_user information,and yes,if user post ad with s_city:7485 then that plugin will insert into oc_t_user s_city that id number,because we are seaching if a user exist by email posted in ad email field.To avoid this we can just leave blank s_city and s_region from oc_t_user(uncomment or delete Params::setParam('regionId', $input['regionId']);
Params::setParam('cityId', $input['cityId'])
let's go back to add from itemaction.
I have a function to detect if js is enabled or not in browser and i hide the form...to avoid the form submition with empty field....The problem is:If user disabled js after page is loaded,then form can be submited.
this if from itemaction.php seems to me to be wrong:
<code>
if( $aItem['regionId'] != '' ) {
if( intval($aItem['regionId']) ) {
$region = Region::newInstance()->findByPrimaryKey($aItem['regionId']);
if( count($region) > 0 ) {
$regionId = $region['pk_i_id'];
$regionName = $region['s_name'];
}
}
} else {
$regionId = null;
$regionName = $aItem['region'];
if( $aItem['countryId'] != '' ) {
$auxRegion = Region::newInstance()->findByName($aItem['region'], $aItem['countryId'] );
if($auxRegion){
$regionId = $auxRegion['pk_i_id'];
$regionName = $auxRegion['s_name'];
}
}
}
</code>
That if allow $aItem['regionId'] =='' to save a empty or numeric value to database
$regionId = null;
$regionName = $aItem['region'];//this can be numeric like my case
the condition should be:
<code>
if( $aItem['regionId'] != '' ) {
if( intval($aItem['regionId']) ) {
$region = Region::newInstance()->findByPrimaryKey($aItem['regionId']);
if( count($region) > 0 ) {
$regionId = $region['pk_i_id'];
$regionName = $region['s_name'];
}
}
else {
$regionId = null;
$regionName = $aItem['region'];
if( $aItem['countryId'] != '' ) {
$auxRegion = Region::newInstance()->findByName($aItem['region'], $aItem['countryId'] );
if($auxRegion){
$regionId = $auxRegion['pk_i_id'];
$regionName = $auxRegion['s_name'];
}
}
}
}
</code>
if $aItem['regionId'] != '' or cityId is not empty we search in database if is numeric we search region by id else by name.
Thx for your time!