Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require anonymous user to register to add content-type

How can I create a form that requires anonymous viewers to register in order to view it?

Right now, I've created a content-type (Submit Plan) which is a primary link available to everyone (anonymous + authenticated). I've restricted 'view' user permissions to anonymous users but they can still see the 'Title' input (I don't want that).

I'd like it so that when an anonymous user clicks on 'Adding a Plan' primary link (the Submit Plan content-type), it goes to the page and says:

  • "You must register for an account" OR
  • Redirects them to the registration page asking them to register to submit a plan.

I've been searching for a module or maybe some code to use but have come up short on this topic. Any help would be appreciated. Thanks!

like image 329
Chetan Avatar asked Nov 06 '22 15:11

Chetan


1 Answers

If you're going to be redirecting users to the registration page, I'd strongly consider using something like logintoboggan to make the registration > node-creation process smooth. Otherwise, registration is a multi-step process and I'd imagine it being easy for users to lose their way back to the Add a Plan form in the process.

For the "show links or show the form" direction, there are at least two ways of approaching that: 1) create a custom page where you "import" the add_plan form (or show the links). 2) modify the node/add/plan page itself, either through themeing or the fapi (the forms api).

  • Here's a promising looking post for the first method: http://drupal.org/node/357895.

  • Here's a place to start with FAPI http://api.drupal.org/api/drupal/developer--topics--forms_api.html/6

  • Here's a post about theming the node form: http://11heavens.com/theming-the-node-form-in-Drupal-6

Without having tried this, I'd probably lean toward method one.

Update: just had another thought: you could also add the plan form to the registration form so they'd fill them out in one shot. I'm not sure of how to do that in general, but the node profile would work if they're only ever going to make one plan, and if not, you can look at how that's put together.

like image 127
sprugman Avatar answered Nov 18 '22 06:11

sprugman