i am working on a website with drupal which has a lot of user restriction pages. when a user is guest and he need to access a webpag开发者_JAVA技巧e he will be asked for user name and password while he logged in he is redirected to the main page or account page .can i make the user to redirect to he same page not to the front page or account page,
If you are rendering a login link in your template file, you can do something like this:
print l("Login","user/login",array('query' => drupal_get_destination()));
If you would like a 'code-less' approach, then please checkout the Rules module.
Once enabled navigate to /admin/rules/trigger/add and create a 'triggered rule', for example:
Label: Redirect User Back to Original Page After Logging In
Event: User -> User Has Logged In
Then click 'Save Changes'... then click 'Add an action'...
Select an action to add: System -> Page Redirect
Here you can set 'php evaluation' to:
echo implode("/",arg());
That will redirect user back to the page they were on before they logged in.
Be careful not to redirect a user to the following paths:
- user/login
- user/register
- logout
You can redirect the user by using the action and trigger
first go to site configuration and then select action where you can define your action.
For ex if you want to redirect the user after login : select redirect to url and hit the create button.
Then go to site building and click on trigger (if have installed it, this module comes up with drupal). Where you will find tabs like cron , user. According to your need select tab and apply your action and assign it.
精彩评论