0

In my website the user can create a node. I want a menu link to appear only after the authenticated user has created the node and not before that.

Is it possible to enable a menu link only when the user has created a node?

For example, the menu items that appear when users log in are:

  • Item 1
  • Item 2
  • Item 3

When users add a node, I want another item that points to another page to appear in the menu. If users didn't create a node, they don't have access to the new item.

How can I do this?

I created another role when the user creates a node using the Rules module, and set permissions for the user with the new role to view the new menu item.

2

One possible solution (there are multiple possible solutions) is to use the rules module to assign a specific role to any user that has created a node (because it seems like users who have created a node are kind of in a specific group of users).

Something like (these aren't exact setting names, it's off the top of my head):
event: create a new node
condition: user doesn't already have this specific role
action: grant user this specific role

Then make it so that users without that role cannot see that menu item.

This can be done in a few ways (this is not an exhaustive list):

  • Use the menu item visibility module to restrict visibility of that menu item if users don't have that role (be aware that the user can still access the page the menu item points to if they know the url - this is not access control).
  • If that item links to a node you can use some sort of content access module like content access to restrict access to that node if users don't have that role. If a user doesn't have access to the node they won't see the menu item pointing to it.
  • If the menu item points to a view you can set the view permission settings so it is not available to users without that role. If they don't have access they won't see the menu item.
| improve this answer | |
2

Here are the steps

For example If you want give permissions for authenticated users to create 'Basic page'

Go to Home » Administration » People (admin/people/permissions) and check the checkbox

Basic page: Create new content and Administer menus and menu items for AUTHENTICATED USER

That's it now authenticated user can create basic page (node/add/page) with menu item.

If you want to generate URL/path aliases automatically, use the Pathauto module

The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change.

| improve this answer | |
  • Okay. But after the user creates the basic page using the menu item say "Add Basic Page", another menu item should be created, for example "Edit Basic Page" and should point to a path. How do I achieve that? – newbie Oct 22 '14 at 17:20
  • @n can't do that. You can edit specified node, but what would unspecified edit link do? – Mołot Oct 22 '14 at 17:26

Your Answer

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

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