Hello,

I am trying to create a primary menu link that would allow registered users to post a submission while redirecting anonymous users to either the login or registration page on the very same link. The problem is that by disallowing anonymous users to post submissions in the permissions page, the link will not appear for them so I have no way of redirecting anonymous users to the login or registration page. I checked out many different websites and they have the feature I want to do for my website. I just do not know how it is done. What is the best and most popular way to achieve this goal? Thank you for your time and I appreciate your help.

Comments

greylogic’s picture

You might need to create a menu item using hook_menu() - http://api.drupal.org/api/function/hook_menu/6

create a page call back like the one below

function page_callback() {
  global $user;
  if(!$user->uid) {
     drupal_goto('user');
  }

  // For authenticted users add the logic below
}

This will redirect all the anonymous users to the login page. Oh one more thing, after adding the function, you need to make drupal rebuild menu for your code to take effect. one of the easy way is to go to module administration page.

--------------------------------------------------------------
My attempt with Drupal - Jaanlo.com

mariner702’s picture

Any other methods?