How do i replace deprecated JRequest

General questions relating to Joomla! 4.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
flasp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 100
Joined: Thu Jan 07, 2010 11:55 am

How do i replace deprecated JRequest

Post by flasp » Sun Oct 24, 2021 7:06 am

I've been using an autologin script in joomla 3.x that is making my joomla 4.x testsite collapse with the following error
"Class JRequest not found".

JRequest is used in the script to get variables for user and password

function onAfterInitialise(){
$this->username = JRequest::getVar('user', null);
$this->password = JRequest::getVar('passw', null);

Can someone tell me how to get those variables in Joomla 4.

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 11245
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How do i replace deprecated JRequest

Post by sozzled » Sun Oct 24, 2021 7:09 am

I need to see the whole "script" to help you. Otherwise, you need to read https://api.joomla.org/cms-3/classes/JRequest.html and figure it out for yourself. See also https://docs.joomla.org/Potential_backw ... n_Joomla_4

Probably using jimport instead of use to include the the class.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

ghazal
Joomla! Explorer
Joomla! Explorer
Posts: 310
Joined: Fri Aug 19, 2005 12:12 pm
Location: Out of my mind ...sometimes

Re: How do i replace deprecated JRequest

Post by ghazal » Sun Oct 24, 2021 9:32 am

Maybe this thread will help you:
JRequest replacement in Joomla 4 - Joomla! Forum - community, help and support
viewtopic.php?f=815&t=989199

flasp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 100
Joined: Thu Jan 07, 2010 11:55 am

Re: How do i replace deprecated JRequest

Post by flasp » Sun Oct 24, 2021 11:05 am

sozzled wrote:
Sun Oct 24, 2021 7:09 am
I need to see the whole "script" to help you. Otherwise, you need to read https://api.joomla.org/cms-3/classes/JRequest.html and figure it out for yourself. See also https://docs.joomla.org/Potential_backw ... n_Joomla_4

Probably using jimport instead of use to include the the class.
Sure, see the attachment
You do not have the required permissions to view the files attached to this post.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2021
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: How do i replace deprecated JRequest

Post by SharkyKZ » Sun Oct 24, 2021 12:45 pm

Code: Select all

$app->input->get('user')
Or if developing only for J4 and above:

Code: Select all

$app->getInput()->get('user')


Post Reply

Return to “General Questions/New to Joomla! 4.x”