User Specific Login Redirect

Your code modifications and patches you want to share with others.
Locked
cifroes
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Tue Sep 14, 2010 3:46 pm

User Specific Login Redirect

Post by cifroes » Thu Sep 16, 2010 2:35 pm

Hi all,

Anyone knows how to show a warning/error message to a user after he logouts?
I tried doing JError::raiseWarning('SOME_ERROR_CODE', JText::_("custom error")); but I think the message queue is not saved properly (should be because the user session is destroyed during logout....

Anyone knows how to achieve this? (yes, I can always redirect to a custom page where I show my message, but that's not what I want)

eppskevin
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Thu Jul 13, 2006 11:04 pm

Re: User Specific Login Redirect

Post by eppskevin » Tue Sep 28, 2010 7:12 pm

Try using this:

Code: Select all

JError::raiseError( 'SOME_ERROR_CODE', JText::_( 'Custom Error' ));
If that doesn't work, you could alter the logout function for com_user in the controller file:

/components/com_user/controller.php(find the logout function, and change it to this):

Code: Select all

function logout()
	{
		global $mainframe;

		//preform the logout action
		$error = $mainframe->logout();

		if(!JError::isError($error))
		{
			if ($return = JRequest::getVar('return', '', 'method', 'base64')) {
				$return = base64_decode($return);
				if (!JURI::isInternal($return)) {
					$return = '';
				}
			}

			// Redirect if the return url is not registration or login
			if ( $return && !( strpos( $return, 'com_user' )) ) {
				$mainframe->redirect( $return );
			}
		} else {
			
			JError::raiseError( 'CUSTOM_ERROR_CODE', JText::_( 'Custom Error' ));
			parent::display();
		}
	}
or...

Code: Select all

function logout()
	{
		global $mainframe;

		//preform the logout action
		$error = $mainframe->logout();

		if(!JError::isError($error))
		{
			if ($return = JRequest::getVar('return', '', 'method', 'base64')) {
				$return = base64_decode($return);
				if (!JURI::isInternal($return)) {
					$return = '';
				}
			}

			// Redirect if the return url is not registration or login
			if ( $return && !( strpos( $return, 'com_user' )) ) {
				$mainframe->redirect( $return );
			}
		} else {
			
			$this->setredirect('index.php?option=com_user',JText::_('Custom Code'));
		}
	}
Do any of these work for you?


Locked

Return to “Core Hacks and Patches”