The user name that appears in head.php, says Hello _____!, doesn't update when you change your name in User Profiles.
Here is the fix, together with: pre-fill Contact Publisher form with logged-in user's Name/Email/Phone.
oc-includes/osclass/frm/Contact.form.class.php
Current:
static public function your_name() {
parent::generic_input_text("yourName", "", null, false);
return true ;
}
static public function your_email($value = null) {
parent::generic_input_text("yourEmail", , null, false);
return true ;
}
static public function your_phone_number() {
parent::generic_input_text("phoneNumber", "", null, false);
return true ;
}
Replace with:
static public function your_name() {
parent::generic_input_text("yourName", osc_logged_user_name(), null, false);
return true ;
}
static public function your_email($value = null) {
parent::generic_input_text("yourEmail", osc_logged_user_email(), null, false);
return true ;
}
static public function your_phone_number() {
parent::generic_input_text("phoneNumber", osc_logged_user_phone(), null, false);
return true ;
}
oc-includes/osclass/helpers/hUsers.php
Find ~line 31:
Session::newInstance()->_set('userId', $user['pk_i_id']) ;
Session::newInstance()->_set('userName', $user['s_name']) ;
Session::newInstance()->_set('userEmail', $user['s_email']) ;
return true ;
Replace with:
Session::newInstance()->_set('userId', $user['pk_i_id']) ;
Session::newInstance()->_set('userName', $user['s_name']) ;
Session::newInstance()->_set('userEmail', $user['s_email']) ;
Session::newInstance()->_set('userPhone',
($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land']) ;
return true ;
Find ~line 48:
function osc_logged_user_name() {
return Session::newInstance()->_get('userName') ;
}
After, add:
function osc_logged_user_phone() {
return Session::newInstance()->_get('userPhone') ;
}
login.php
Find ~line 55:
Session::newInstance()->_set('userId', $user['pk_i_id']) ;
Session::newInstance()->_set('userName', $user['s_name']) ;
Session::newInstance()->_set('userEmail', $user['s_email']) ;
Replace with:
Session::newInstance()->_set('userId', $user['pk_i_id']) ;
Session::newInstance()->_set('userName', $user['s_name']) ;
Session::newInstance()->_set('userEmail', $user['s_email']) ;
Session::newInstance()->_set('userPhone',
($user['s_phone_mobile'])? $user['s_phone_mobile'] : $user['s_phone_land']) ;
oc-includes/osclass/user.php (or UserActions.php)
Find ~line 103:
function edit($userId)
{
$input = $this->prepareData(false) ;
$this->manager->update($input, array('pk_i_id' => $userId)) ;
After, add:
// Update user vars in $_SESSION
Session::newInstance()->_set('userName', $input['s_name']) ;
Session::newInstance()->_set('userPhone',
($input['s_phone_mobile'])? $input['s_phone_mobile'] : $input['s_phone_land']) ;
user-non-secure.php
Find ~line 39:
$userManager->update(
array('s_email' => $userEmailTmp['s_new_email'])//, 's_pass_code' => $code)
,array('pk_i_id' => $userEmailTmp['fk_i_user_id'])
);
After, add:
// Update user vars in $_SESSION
Session::newInstance()->_set('userEmail', $userEmailTmp['s_new_email']) ;
Now when user changes their name, changes to header.php will appear immediately,
instead of at next login.
Now when user is viewing item page, the "contact publisher" fields Name/Email/Phone will be pre-filled with logged-in user's data.