An example for your particular use-case would look like the following:
- Make a new directory in sites/all/modules called "mywebform_extra".
- Make a new text file in sites/all/modules/mywebform_extra called mywebform_extra.info. Put this inside of it:
name = Webform Extra
description = Customizations for the Webform module.
core = 6.x
package = Webform
dependencies[] = webform
- Make a new text file in sites/all/modules/mywebform_extra called mywebform_extra.module. Put this inside of it:
<?php
/**
* Implementation of hook_form_alter().
*/
function mywebform_extra_form_alter(&$form, &$form_state, $form_id) {
// Add validation for a particular Webform node:
if ($form_id == 'webform_client_form_44') {
// Simply add the additional validate handler.
$form['#validate'][] = 'mywebform_extra_validate_44';
// Add the submit handler after the existing Webform submit handler,
// but before the second Webform handler. Pop off the first one and add
// ours second.
$first = array_shift($form['#submit']);
array_unshift($form['#submit'], $first, 'mywebform_extra_submit_44');
}
}
/**
* Validation handler for Webform ID #44.
*/
function mywebform_extra_validate_44(&$form, &$form_state) {
global $user;
if (!isset($user->roles[4])) {