Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2. // $Id$
  3.  
  4. /**
  5. *@file
  6. *Support for dubious legal agreement during user registration.
  7. */
  8.  
  9. /**
  10. * Implementation of hook_user().
  11. */
  12. function legalagree_user($op, &$edit, &$user, $category = NULL){
  13.     switch($op) {
  14.         // User is registering.
  15.         case 'register':
  16.         // Add a fieldset containing radio buttons to the
  17.         // user registration form.
  18.         $fields['legal_agreement'] = array(
  19.         '#type' => 'fieldset',
  20.         '#title' => t ('Legal Agreement')
  21.         );
  22.         $fields['legal_agreement']['decision'] = array(
  23.           '#type' => 'radios',
  24.           '#description' => t('Registrandoti a %site-name, accetti le condizioni
  25.           della nostra carta della privacy. Ai sensi delle leggi esempio.
  26.           inserire tutto il testo che serve.',
  27.           array('%site-name' => variable_get('site_name','drupal'))),
  28.           '#default_value' => 0,
  29.           '#options' => array(t('Non accetto'), t('Accetto')),
  30.           );
  31.           return $fields;
  32.          
  33.           // Fields values for registration are being checked.
  34.           case 'validate':
  35.           //Make sure the user selected radio button 1 ('Accetto')
  36.           // The validate op is reused when a user updates information on
  37.           // the 'My account' page, so we use isset() to test whether we are
  38.           // on the registration page where the decision field is present.
  39.           if (isset($edit['decision']) && $edit['decision'] != '1') {
  40.             form_set_error('decision', t('Devi accettare le condizioni prima
  41.             che la registrazione sia complete.'));
  42.           }
  43.           break;
  44.           // New user has just been inserted into the database.
  45.           case 'insert':
  46.           // Record information for future lawsuit.
  47.           watchdog('user', t('User %user agreed to legal terms',
  48.           array('%user' => $user->name)));
  49.           break;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement