Plugin Joomla 3.x redirect joomla user after login Topic is solved

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
ccpspydog911
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sat Apr 17, 2021 3:33 pm

Plugin Joomla 3.x redirect joomla user after login

Post by ccpspydog911 » Sat Apr 17, 2021 3:47 pm

I start create an extension after user login in home page, it'll redirect user to specific page i want like this.

Image

But nothing happen when i login. it still on home page and don't redirect to page i adjusted.

This my xml code:

Code: Select all


<?xml version="1.0" encoding="utf-8"?>
<extension version="3.9" type="plugin"  group="user" method="upgrade">
    <name>New Login</name>
    <author>Jont Wnaw</author>
    <version>1.0.0</version>
    <description>Plugin new</description>

    <files>
        <filename>newlogin.xml</filename>
        <filename plugin="newlogin">newlogin.php</filename>
        <filename>index.html</filename>
    </files>
 
    <config>
        <fields name="params">
            <fieldset name="basic" label="Mylogin Setting">
                <field name="menu_id" type="menuitem" label="Select Redirect Page"/>
            </fieldset>
        </fields>
    </config>
</extension>

And newlogin.php

Code: Select all


<?php
error_reporting(E_ALL);
ini_set('display_erors',1);

defined('_JEXEC') or die('Access Deny');

class plgUserMyLogin extends JPlugin
{
   
    public function onUserLogin($user,$options=array()){
        $menu_id=$this->params->get('menu_id');
        $app=JFactory::getApplication();
        $menu=$app->getMenu();
        $item=$menu->getItem($menu_id);
        $url=JRoute::_($item->link.'&itemId='.$menu_id);
        $app->redirect($url,'Login !!');
    }
}
?>
What did I do wrong?

gws
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4268
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Plugin Joomla 3.x redirect joomla user after login

Post by gws » Sat Apr 17, 2021 3:58 pm

quite possibly your server is set to handle index.php before index.html

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 39841
Joined: Sat Apr 05, 2008 9:58 pm

Re: Plugin Joomla 3.x redirect joomla user after login

Post by Webdongle » Sat Apr 17, 2021 4:20 pm

What happens when you set the redirect after login in the menu item or module?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

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

Re: Plugin Joomla 3.x redirect joomla user after login

Post by SharkyKZ » Sat Apr 17, 2021 6:39 pm

Your plugin class doesn't match plugin name in manifest. Should be PlgUserNewLogin (casing doesn't matter) or the name in manifest should be mylogin.

ccpspydog911
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sat Apr 17, 2021 3:33 pm

Re: Plugin Joomla 3.x redirect joomla user after login

Post by ccpspydog911 » Sun Apr 18, 2021 2:50 am

SharkyKZ wrote:
Sat Apr 17, 2021 6:39 pm
Your plugin class doesn't match plugin name in manifest. Should be PlgUserNewLogin (casing doesn't matter) or the name in manifest should be mylogin.
Thanks!! it worked

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 27729
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Plugin Joomla 3.x redirect joomla user after login

Post by Per Yngve Berg » Sun Apr 18, 2021 8:05 am

Mod.Note: Relocating the topic from Extensions to the coding forum.


Post Reply

Return to “Joomla! 3.x Coding”