0

I have created one webform with Name,Email id, Address fields. if user is login in name field already fill with 'login user name' and no one login then its fill with 'Anonymous'.

my issue is if user login its fill with login user name but not login then filed should be blank not fill with 'anonymous'.

Please help...

1 Answer 1

1

You can alter the webform and put some and achieve this.

<?php 
    function module_name_form_alter(&$form, &$form_state, $form_id) {   
   // module_name = your custom module name.
       if($form_id =='webform_name')
        // webform_name = your webform id
           //check condition for non login user
           if(!user_is_logged_in()){
            {           
             $form['submitted']['field_name']['#default_value']= 'anynomous';  
             // field_name = Field name        
            }
         }
    }

    ?>

You also need to debug using dpm. Which helps you solve you problem easily.

I believe that you can also do this using Rules module. You also need to try for this.

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.