The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
PostPosted: Thu Sep 16, 2010 2:35 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Sep 14, 2010 3:46 pm
Posts: 16
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)


Top
 Profile  
 
PostPosted: Tue Sep 28, 2010 7:12 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jul 13, 2006 11:04 pm
Posts: 45
Try using this:

Code:
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:
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:
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 



Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group