I am interested to implement a menu item on the top of my front page as "submit story". I want that this menu item is always visible to everybody (registered or unregistered users both) but if the user is not logged in and clicks on "submit story" menu item then he would be redirected to login/register page and once he logs in, he would be redirected to actual story submit page (/node/add/story). This type of functionality is available at the following sites-

  1. http://www.24-7pressrelease.com
  2. http://www.prlog.org/pub/
  3. http://www.prweb.com/
  4. then click "submit release".

Thanks in advance for any kind of help.

Comments

3cwebdev’s picture

The way I would do it is to write a small module that creates the menu path to submit the story.

The module's path would point to a 'page callback' routine to handle the logic.. This routine could easily check if user is anonymous or not. And if so, write the original destination to the user's $_SESSION variable for later retrieval after logging in or registering.

This is just a quick overview of how I would tackle it and there may be issues to tackle or better ways to do it.

Hope this helps.

aac’s picture

Thanks for your response.

Is there any other way instead of creating a new module??

Actually i have tried this in the following way-
->I have created a menu item "submit story" which is pointing to "node/add/story", which is a direct link to the create story page.
->But only authenticated users are allowed to submit an story, so it is not visible to non-logged in users.
->Since i am knowing the path (alias) of the "submit story" menu link, so if try to access this link as an unregistered user, it will give me "access denied" page. Now if i use "logintoboggan" module and enable the setting "Present login form on access denied (403): Enabled", then a similar kind of functionality is partially achieved because the "submit story" menu link is still not available to unregistered users.

Any comments/suggestions welcome!!!

---~~~***~~~---
aac

aac’s picture

I am still trying to find the right solution to make the menu item visible to everybody. If anonymous user clicks on it, then he would be redirected to login/register page else he would be redirected to either "node/add/story" page or to "access denied page" depending upon the access rights given to that user. Please guide me in the right direction!!

---~~~***~~~---
aac

3cwebdev’s picture

I don't know if there is another way, but writing a small module is pretty simple. It may only take a little while to write some code to provide the path. Then your menu items can link to this path. The path from your module would simple link to custom routine. Now you have complete control over what happens!

You can check for anonymous status, write to the session variable, redirect to another path, etc.

This link should help you get started, it really isn't very hard once you dive in.

http://drupal.org/node/231276

aac’s picture

Thanks for your response!!
ok!! I am going through this link to learn how to create a module for drupal6. Once i go through this tutorial, i will start creating the module. Hopfully you would be helping me in this development as i am new to Drupal.
On the other side, i also tried to achieve the functionality in the following way-
->I have created a "page" with title "Submit Story" and a menu link "Submit Story". In this way this menu link is visible to everybody (which i want) whether anonymous or registered.
->This page contains the information that
if you are a new visitor then you will have to register on this site for submitting the story
elseif
you have to login to submit the story.
->I also published the login block on this page in the content area.
->Now if the user logs in from this page then i can redirect him to "node/add/story" page by using the "login destination" module by using php in the configuration of that module.
At present i am not able to properly write the code for redirecting to "node/add/story" page if someone logs in from Submit story "page".
What are your comments on it??
Thanks in advance for your suggestions!!

---~~~***~~~---
aac

ressa’s picture

This triggered rule will redirect registered users to node/add/article, when they click on a "Create article" Primary link, while redirecting anonymous users to a "conditions for posting" page:

1. Create a new page, for example "Create article", include a link to the registrations page (user/register) on the page and give the page the alias "create-article". Remember to add a Primary link.
2. Install Rules and Path Rules modules
3. Create a new triggered rule, Label: "Redirect registered users to node/add/article". Event: User is going to view a page
Check path = create-article
AND
User has role(s) = authenticated user
DO
Page redirect = node/add/article

You could also just redirect anonymous users directly to user/register directly by adding another rule, in which case the "Create article" of course doesn't need any content.

aac’s picture

Thanks ressa for your help. It would be much helpful in my future projects.

---~~~***~~~---
aac