0

I created a new content type in Drupal 7 and I want to make a template to customize the node add page for that content type. I want to be able to check if the user is authenticated with Facebook before they can use the node add form. If user is not authenticated then I will show them a paragraph explaining that they need to authenticate via facebook before they can use this form. I want them to always see the form link but they can only use the form if they are authenticated to facebook. I just don't know where to put it. Is it possible to make a template file specifically for that node add page so that I can include my logic?

3
  • ... and what do you want to do if the user is not FB-authenticated? More information is needed; you're just repeating what you've mentioned in the comment. Don't be shy and write an essay :)
    – user7667
    Commented Jul 20, 2012 at 15:20
  • Lol ok. How's that? Commented Jul 20, 2012 at 15:24
  • Better and I've updated my answer :)
    – user7667
    Commented Jul 20, 2012 at 15:44

1 Answer 1

0

Hiding options such as publishing and URL aliases is accomplished through the use of user roles and permissions. Visit /admin/people/permissions on your site to see what I mean. Enable the help module for more (contextual) assistance.

If you want to perform additional modification beyond basic access control, then, seeing as to how you are attempting to customise a form, you would need to implement a Drupal hook named hook_form_alter(). You will need to do this in a custom module - if you haven't done this before, it's a lot easier than it sounds :)

There should be plenty of information and guides on SE, d.o as well as Google on how to use this hook to modify forms. But the one reference that you definitely need to be aware of is the Form API reference.

Since you want links to the node-add form to be visible, rather than controlling access to the page based on the FB-authentication status, you can check the status during the form_alter and either add a message and disable the form, or as is usually done, set an error message or notice (using drupal_set_message()) and redirect them to a page where they can log in via FB; the message/notice will be displayed at the destination.

10
  • I see what you mean. However, I still need to add some additional logic to that add content type page. Is what I am trying to do possible? Commented Jul 20, 2012 at 14:35
  • I have updated my answer with more information. You can also attempt to modify the markup of the entire page via a template file. But it is usually unnecessary as you can perform most of the nudges via the form_alter. You can also modify the structure of form elements if need be via .tpl files. But again, in most cases it is unnecessary.
    – user7667
    Commented Jul 20, 2012 at 14:44
  • The logic i want to edit is not specific to the form itself. I want to show a menu link for this content type but I want to check if user is authenticated to facebook when they click it. Which is why i want to add my logic to the node/add but only for that specific content page. Make sense? Making i'm going about this all wrong. Commented Jul 20, 2012 at 14:57
  • If that's the case, please improve your question with lots of detail stating exactly what it is that you are looking to do.
    – user7667
    Commented Jul 20, 2012 at 14:59
  • OK everything you're saying makes perfect sense and it sounds like the way to go. Just need some clarification on how to make a custom module work specifically for this. Do I just make a custom module and then call it manually? If so where would I call it manually from? Or should I just hardcode the form id in my custom module? Commented Jul 20, 2012 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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