Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2350

Joomla! 4.x Coding • Login programmtacially in Joomla 4

$
0
0
Hello,

I'm trying to use a script to login in Joomla 4 programmatically. Therefore I'm using this:

Code:

use Joomla\CMS\Factory;use Joomla\CMS\Plugin\PluginHelper;use Joomla\Event\Dispatcher as EventDispatcher;$db = JFactory::getDbo();$q = "SELECT * FROM `#__users` WHERE id = ".$userid;$user = $db->setQuery($q)->loadAssoc();               $dispatcher = new EventDispatcher();// Initiate log in$options = array('action' => 'core.login.site', 'remember' => false);$results = $dispatcher->triggerEvent('onUserLogin', array($user, $options));
Sadly it doesn't work. I don't get any errors but there is no login. Could you help me - what I have to edit here?

Statistics: Posted by Rusler — Sun Feb 04, 2024 2:37 pm



Viewing all articles
Browse latest Browse all 2350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>