问题
I have a "Join Now" menu option on the unregistered user front end. When a new user selects that menu option, they're presented the registration form. On completion they get a notice that a confirmation e-mail has been sent to them.
All standard stuff.
So... the user goes to their e-mail inbox, finds the confirmation e-mail and clicks the link. They're brought back to the site and they are still under the "Join Now" menu option...
https://www.example.com/index.php/join-now?view=login
So... the complete the login form, as expected. And there's the rub.
The 'Join Now' menu option is tied to the unregistered user permissions level and once they log in, it is no longer an active menu option. So, every time a new user logs in, they get an error message at the top of the page in the "drawer" box.
Error
You are not authorised to view this resource.
How do I fix that so that when they log in they get redirected back to the 'Home' menu and we don't get this error message? For the life of me I can't seem to figure that out, and I know it should be simple.
回答1:
You can put this inside your template:
$app = JFactory::getApplication();
$user = JFactory::getUser();
//redirect user if logged in
if ($user->id > 0) $app->redirect('index.php/menuwhereyouwanthimtogo');
来源:https://stackoverflow.com/questions/20912897/access-permissions-error-when-user-confirms-e-mail