4
votes

I have successfully created a custom registration page in joomla 2.5 and based on the user type i want to redirect the users to different views after log in. How can i achieve this? Do i need to create an Authentication plugin or a custom log in module?

Thanks

3
a custom registration page using the default Joomla registration form? or Community builder? or something else?Lodder
i create my custome registration form not joomla nor community buliderOlolade enifeni

3 Answers

1
votes

What about the non-commercial "Redirect on Login" extension: http://extensions.joomla.org/extensions/access-a-security/site-access/login-redirect/15257 which redirects users on login based on access level/user group or a similar extension in the Login Redirect category in JED: http://extensions.joomla.org/extensions/access-a-security/site-access/login-redirect

1
votes

Try this,

Joomla have a module for login purpose you can use that or just check com_users/view/

for redirecting after successful login in joomla from any page you can use

<input type="hidden" name="return" value="<?php echo base64_encode("your return url"); ?>" />

This hidden field should found inside your login module form some thing like below.

<form action="<?php echo JRoute::_('index.php?option=com_users&task=user.login'); ?>" method="post">

        <fieldset>
            <?php foreach ($this->form->getFieldset('credentials') as $field): ?>
                <?php if (!$field->hidden): ?>
                    <div class="login-fields"><?php echo $field->label; ?>
                    <?php echo $field->input; ?></div>
                <?php endif; ?>
            <?php endforeach; ?>
            <button type="submit" class="button"><?php echo JText::_('JLOGIN'); ?></button>
            <input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url',$this->form->getValue('return'))); ?>" />
            <?php echo JHtml::_('form.token'); ?>
        </fieldset>
    </form>

You just need to put your return url in the hidden field with base64_encoded Joomla will redirect to this url when the login was success.

This is not a core file editing if you required to redirect after authentication, that means you already providing a login form that should have hidden field like return or just add it.

In another case if you want to know just the redirection option.

$mainframe = JFactory::getApplication();
$mainframe->redirect("your redirect url",'message' ,'message type');

Hope its helps...

0
votes

Its Just short cut method in 3.x

Open Path in Joomla plugins\authentication\cookie\cookie.php

In function onUserAfterLogin($options) on top,

$user   = JFactory::getUser();
        $groups = $user->get('groups');

            if(in_array(10, $groups)) 
            {
             $url = JRoute::_('index.php?option=com_students');
             $this->app->redirect($url);
            }