I have a link http://examplesite.com/my-site#userid. Only authenticated users have permission to view this link. If unauthorized users follow this link I have created a redirect using drupal_goto('another-page'). But the unauthorized users are now being redirected to http://examplesite.com/another-page#userid. The userid part is not removed. Could someone help me with this.Thanks

When I go to http://examplesite.com/my-site#userid the following function is being called:

function my_page() {
    if($user->category == 0){
            drupal_goto('another-page'); //user gets redirected to http://examplesite.com/another-page#userid
              //Corresponding code
  • Please share your code so we can check. – Jayendra Kainthola Oct 16 '13 at 11:11
  • tanx for the reply @Jayendra. I have edited my question likewise. – Outlooker Oct 16 '13 at 11:16
  • Unless you add a fragment to the drupal_goto() options there's no reason it would be added to the redirect URL. Have you confirmed this isn't a browser problem by trying a different machine/browser combination? – Clive Oct 16 '13 at 11:46
  • tanx for the reply @Clive.I have sure it is not a browser problem.I have checked it – Outlooker Oct 16 '13 at 11:49
  • I guess the next step is to force a new fragment to make sure the problem is definitely Drupal related, and not your server/client. If you use drupal_goto('another-page', NULL, 'test'); instead, does the fragment change to #test, or does it stay as #userid? – Clive Oct 16 '13 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.