I have this code which i use now:
function onAfterInitialise(){
$this->username = JRequest::getVar('user', null);
$this->password = JRequest::getVar('passw', null);
if(empty($this->username) || empty($this->password)) return true;
$result = $this->params->get('authmethod','1') === '0' ? $this->plainLogin() : $this->encryptLogin();
$redirectURL = $this->params->get('urlredirect', null);
if(!empty($redirectURL)){
if(!JError::isError($result)){
$app = JFactory::getApplication();
$app->redirect($redirectURL);
}
}
}
I want it to get the var even if it is user
or USER
and also for passw
or PASSW
.
How to do it?
Thanks
The second parameter is the default value and its default value is null
. So as long as there are only 2 options - and not stuff like User
as well - you can simply do:
$this->username = JRequest::getVar('user', JRequest::getVar('USER'));
$this->password = JRequest::getVar('passw', JRequest::getVar('PASSWD'));
Add some additional checks to the code:
$this->username = JRequest::getVar('user', null);
if (empty($this->username)) {
$this->username = JRequest::getVar('USER', null);
}
$this->password = JRequest::getVar('passw', null);
if (empty($this->password)) {
$this->password= JRequest::getVar('PASSW', null);
}
// And then proceed as in your code
if(empty($this->username) || empty($this->password)) return true;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.