Require anonymous user to register to add content type

How to create a form for which anonymous viewers must register to view?

Currently, I have created a content type (Submit Plan), which is the main one available to everyone (anonymous + authenticated). I restricted the user’s viewing rights to “anonymous users,” but they can still see the “Title” input (I don’t want this).

I would like that when an anonymous user clicks on the “Add a plan” link (the content type is “Send a plan”), he goes to the page and says:

  • "You must register for an account" OR
  • Redirects them to the registration page with a request to register to send the plan.

I was looking for a module or maybe some kind of code to use, but not much in this matter. Any help would be greatly appreciated. Thank!

+5
source share
2 answers

If you are going to redirect users to the registration page, I would highly recommend using something like logintoboggan to make the registration process> node-main. Otherwise, registration is a multi-step process, and I think that it will be easy for users to return to the “Add Plan” form in the process.

" " : 1) , "" add_plan ( ). 2) node/add/plan, , fapi ( api).

, , , .

: : , . , , node , , , , .

+1

.

" " :

<?php
  global $user;

  if ($user->uid == 0) {
     print '<a href="/user/register">Add a Plan</a>';
  } else {
     print '<a href="/node/add/submit-plan">Add a Plan</a>'l;
  }
?>

, UID. 0 , , . node Submit Plan. , . , .

, , .

+1

All Articles