Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $Id$
- /**
- *@file
- *Support for dubious legal agreement during user registration.
- */
- /**
- * Implementation of hook_user().
- */
- function legalagree_user($op, &$edit, &$user, $category = NULL){
- switch($op) {
- // User is registering.
- case 'register':
- // Add a fieldset containing radio buttons to the
- // user registration form.
- $fields['legal_agreement'] = array(
- '#type' => 'fieldset',
- '#title' => t ('Legal Agreement')
- );
- $fields['legal_agreement']['decision'] = array(
- '#type' => 'radios',
- '#description' => t('Registrandoti a %site-name, accetti le condizioni
- della nostra carta della privacy. Ai sensi delle leggi esempio.
- inserire tutto il testo che serve.',
- array('%site-name' => variable_get('site_name','drupal'))),
- '#default_value' => 0,
- '#options' => array(t('Non accetto'), t('Accetto')),
- );
- return $fields;
- // Fields values for registration are being checked.
- case 'validate':
- //Make sure the user selected radio button 1 ('Accetto')
- // The validate op is reused when a user updates information on
- // the 'My account' page, so we use isset() to test whether we are
- // on the registration page where the decision field is present.
- if (isset($edit['decision']) && $edit['decision'] != '1') {
- form_set_error('decision', t('Devi accettare le condizioni prima
- che la registrazione sia complete.'));
- }
- break;
- // New user has just been inserted into the database.
- case 'insert':
- // Record information for future lawsuit.
- watchdog('user', t('User %user agreed to legal terms',
- array('%user' => $user->name)));
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement