Display the link but not the CCK form - drupal

I have created a form using add new content type and cck fields. I want anonymous users to view the menu item to this form but not the content. So when users click on the link they should get redirected to login page. I have granted the permissions of access all content. Any suggestions please.
Thanks
Kanwal

create node-{YOURCONTENTTYPE}.tpl.php in your theme, then write next code:
<?php
global $user;
if (!$user->uid) {
drupal_set_message('You should login before see this content type');
drupal_goto('user');
}
?>
//HERE CODE FROM STANDARD node.tpl.php of your theme

I would never use the theme layer for access control and redirection, as Nikit suggests.
You could simply create a normal menu link to 'user/login' with "Create content" as menu title. Drupal will automatically hide it when you're logged in.
An even better option, IMHO, is to use the Inline Registration module. As the module page says: "Inline Registration allows anonymous users to register via the node/add page, thus removing a step/barrier from the user actually publishing content." Try it, I think it's a huge usability improvement.

Related

Wordpress - Hide a page when a user try to navigate to it writing the URL

Example: I created a custom post type "movie". I added links of some movie posts in the nav menu, and it's ok if a user navigates to a post writing in the browser the URL (like www.site.com/movie/apocalypse-now) but I don't want that the user navigates to the page www.site.com/movie (that lists all the movies).
Is there a way to hide that page?
Why not register has_archive to false in your register_post_type() function?
Would be a solution if you want to disable the post type archive.
You need Advanced Access Manager if you're willing to use plugin.
Filter Admin Menu
Filter Admin Panel
Filter Dashboard Widgets
Filter Metaboxes
Manage Comments
Manage Capabilities (Create, Delete)
Manage User Roles (Create, Edit, Delete)
Manage Access to your Posts, Pages or even Custom Post Types
Give possibility to promote Users
Manage Admin Menu Order
Manage other Administrators
Exclude Front-end Pages from Navigation
You can try to create an rewrite rule pointing to your homepage or e.g. the first movie.
Here is exactly the thing you like to do, just the opposite: ;)
http://www.ballyhooblog.com/custom-post-types-wordpress-30-with-template-archives/

Embed registration page on another page in Drupal?

Currently you can get to the registration page by going here: user/register
I need to be able to embed the registration form on ANOTHER page. How do I do that?
You could try the method suggested here: http://drupal.org/node/248275
a.k.a. embed the form using the PHP Code input filter:
<?php
print drupal_get_form('user_register');
?>
However, there will be a few gotchas with trying to embed the user registration page anywhere besides /user/register, because of the way Drupal's User module is set up.
It might be better for you to form_alter the user registration form, so you can customize it to fit your needs. Or, you might be able to get by with adding a block specifically to the user registration page.
What exactly are you trying to achieve by adding the registration page somewhere else?

Drupal: building a users-submitted testimonials page

What's the easiest way to create a testimonial page in Drupal ?
I need the users be able to add a comment on the bottom of the page, and I need to approve them before they can be published.
I could use views + webform module for it ? Or is there something simpler ?
thanks
Create a content type called "Testimonials" and set it to default Unpublished. Call the Title field "Name" and the body field "Testimonial".
Create a View called testimonials with a page attachment that lists out nodes of type "testimonial" with a filter for Published = Yes. Set the path to "/testimonials".
Use the Form Block module (http://drupal.org/project/formblock) to put the Node Add form for the Testimonial content page into a block.
Configure the block you created to appear at the bottom of the testimonial page (your theme should have a "Content bottom" region, if not you'll need to add one by editing the theme's page.tpl.php and $theme.info file.
To approve a testimonial, go to the content list, filter by Type: Testimonial and Status: Unpublished then use the checkboxes and the drop-down to change the status to "Published".
This will provide a page that lists testimonials, with an "add testimonial" form at the bottom of the page, and all testimonials must be approved before they will appear on the site.
If your criteria for a testimonial is just a block of text then creating a "testimonial" content type would work. You could allow users to create them but require admin approval to be published.
You can also change the access control for comment approval
Edit:
This was going to be my follow-up comment when you clarified that you wanted a form at the bottom of an existing page.
I don't know if this works, but try
viewing the HTML source of
/node/add/testimonial in your
browser and copy everything from
<form action="/node/add/page"... to
the closing </form> tag.
Gah. That sounds hideously complicated. If you want a form at the bottom of an existing page then maybe the plugin you mentioned is the best option (but I haven't researched it).

custom page in Drupal

hi i have created a website in drupal.In this registration page can be access by following url
http://mysite.com?q=user/register
But i want to make a custom page for registration.
Please give me some guide line , i don't have any idea for this
You want to modify the user registration form,
http://www.google.ca/search?client=safari&rls=en&q=user+registration+template+drupal&ie=UTF-8&oe=UTF-8&redir_esc=&ei=Jn0dTdTzI466sQP4uZ2PCg
a) hook_form_user_register_alter() documentation at http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_form_alter/6 b) if you totally cant do what you want with a happy little form altering then you can always hook_menu_alter() the page and use whatever page callback you desire instead of drupal_get_form.
Goto admin/build/modules
Enable Profile module
Add fields in profile and while adding a field make it 'visible during registration'

Creating a custom content type in drupal

i tried to create a custom content type in drupal but unnecessary features like Title, Menu settings, and Revision Information, URL aliases come with it which i don't really want ..coz it doesn't mean anything to the user..
how can i hide all those things, just preserving the fields(say only 3 fields from CCK) that i want only for this custom content type??
thanks..
You can automatically generate titles using the auto_nodetitle module, which also enables you to remove the title field from the node submission form.
As others have mentioned above, most of the other form elements don't appear to non-admin users anyway.
With auto_nodetitle module, you can hide it, not remove it. Then, simply assign a title like "your-content-type-nid", so it will be different for each node (nid will be different).
That would be a better title than an empty one.
You will need to do a combination of things to do what you want. One of those is to add the module auto_nodetitle suggested by others. You can hide the "Body" by removing the "Body field label" from the edit screen for your custom content type. Lastly is that you will have to do the right settings for your CCK fields.
If you have CCK fields you want them to be able to edit and others you do not want them to edit, you will need to enable the Content Permissions module in the CCK section of the modules admin page. Once you've done that, you can go to the role permissions page and set what roles have access to which fields. While permissions can potentially hide CCK fields from the user, you can also control what fields are in the teaser, node, and RSS views via the "Display fields" section of your content type editing screens.
Menu settings, revision info and URL alias type info is admin stuff. If you create a new user that doesn't have admin permissions, I'm pretty sure they won't see it.
Can try some thing like below using hook_form_alter.
function my_module_form_alter(&$form, $form_state, $form_id) {
if($form_id='company_node_form'){
$form['menu']['#prefix'] ='<div style="display:none">';
$form['menu']['#suffix'] ='</div>';
$form['revision_information']['#prefix'] ='<div style="display:none">';
$form['revision_information']['#suffix'] ='</div>';
$form['author']['#prefix'] ='<div style="display:none">';
$form['author']['#suffix'] ='</div>';
$form['options']['#prefix'] ='<div style="display:none">';
$form['options']['#suffix'] ='</div>';
}
}
You might want to try the NodeFormCols module. It does several handy things, among them is to add a Manage Form button which allows you to hide most fields in an input form.

Resources