3

I have a blog posts, and when an anonymous user visits it and and clicks the link "Login" or "Register" to post comment (under blog entry), then its url looks like this:

http://example.com/user/login?destination=node/55%23comment-form

But I don't want that parameter of destination here. I just want a simple link like so:

http://example.com/user/login

Any suggestions?

3 Answers 3

4

Finally I got the solution by using hook_url_outbound_alter in my theme template. I tested it successfully.

function moon_url_outbound_alter(&$path, &$options, $original_path) {
 // here "moon" is my theme, use your own.
  switch ($path) {
  case 'user/login':
  unset( $options['query']['destination'] );
  break;
 }
}
1

you could create your own block to easily accomplish this:

  • create a new block allowing Full HTML, then insert your own link to login / register
<a href="/login">Sign In</a> / <a href="/register">Register</a> to post comments
  • limit it's visibility to the content types you want, in the placement you want, and only show for anonymous users

  • use some css (or a preprocess function override if you want to get fancy) to hide the existing element

3
  • your idea is good @Geoff but this is not suitable solutoion in this situation. Because i will have to add this new block under every node types and also under each comment. So this is time killing and lenghty process !
    – WaQaR Ali
    Commented Apr 22, 2015 at 9:39
  • setting up a block only takes a few minutes at most, and it only needs to be done once... If it's a lengthy process, you're probably doing something wrong
    – Geoff
    Commented Apr 22, 2015 at 15:00
  • i like your last point "preprocess function override" this has realy helped me to solve my problem, thanks
    – WaQaR Ali
    Commented Apr 23, 2015 at 5:39
0

Would the Login Destination module help?

1
  • sorry, this has not help me. This module just change destination after login but provide any help to finish destination parameter. Because that destination parameter gains value before login but this module start action after login. A simple rule also provide same functionality like this module but not according to my needs !
    – WaQaR Ali
    Commented Apr 21, 2015 at 10:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.