Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Friday, June 14, 2013

Add custom address city user profile fields joomla 2.5

If you want to add basic location fields in user profile both for registration and profile like city, country, address, postcode you don't have to install any plug-ins .. Joomla 2.5 gives the option to do that by default :)

Here is how it goes:

Step 1: Go to 'Extensions' -> 'Plug in Manager'
Step 2: Search 'Profile'
Step 3: Enable the plug in called 'User - Profile', its disabled by default.

Step 4: Click on plugin and from right menu select the fields you want.
Step 5: Save & Close and you are done :)

Wednesday, August 8, 2012

Joomla 2.5 - Redirect to login page with return URL

If you have a private page that is supposed to be viewed only by registered users and if URL is accessed directly or is accessed on session expire you want to redirect user to login page and on successful login return him to the requested page then simply make a function named something like 'validateUser' and call it for all such views. Here is the brief and comprehensive function:


function validateUser()
{
        $user = JFactory::getUser();
        $userId = $user->get('id');
        if(!$userId)
        {
            $mainframe = &JFactory::getApplication();
            $return = JFactory::getURI()->toString();
            $url  = 'index.php?option=com_users&view=login';
            $url .= '&return='.base64_encode($return);
            $mainframe->redirect($url, JText::_('You must login first') );
            return false;
        }
        return true;
}

Note: If you are trying to do something similar for Joomla 1.5 note you would have to use 'option=com_user' instead of 'users'.