I wanted to create a "Contact Us" webform, which should have following fields-

  1. Name
  2. Email Address
  3. Contact No
  4. Message

For an anonymous user, all of these fields should display.However for logged in user, field 1, 2 and 3 should not be displayed.

I don't see any option in webform to set a filed in such a way, so that only anonymous user can see it.

I tried to create two webform and assigned different-2 submission access but unknowingly now the website is having two menu items.

2 Answers 2


You can do it with Webform Component Roles, this module provides a way to allow access to each webform component to only selected roles.

This module will allow webform creators to restrict which roles can use webform components per webform.

  • Cool.... Awesome. This is what I was looking for. Excellent. Thank you Bala.
    – ravi
    Mar 8, 2014 at 17:33
  • @RaviJoshi your welcome!!!!!!!!
    – Bala
    Mar 8, 2014 at 17:35

you need to try this coding

function _form_edit_module_form_alter(&$form, &$form_state, $form_id) {   
 if($form_id =='webform_form_id') {           
  //check login user enter in site
  global $user;
  if ($user->uid) {
     $form['component_name']['#attributes']['disabled'] = true;

and also you need check Webform Conditional module

  • Webform Component Roles was enough for me. Thanks a lot.
    – ravi
    Mar 8, 2014 at 17:34

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.