Drupal 7 - User Restrictions Batch Module

Parent Feed: 

This module extends the existing user_restrictions module by providing a mechanism for the bulk import of prohibited words in the screen name during user registration. This is useful to ensure that on a community site no users attempt to create accounts with offensive names. Without this module, any admin wishing to add a few hundred words to the user_restrictions list would face quite an onerous chore to type them all in. With the module, they can be cut and pasted from an existing source into a textarea in one go. The textarea allows for carriage return / linefeeds and will also remove commas between words.

The module was very easy to put together, so I don't believe there is anything requiring further expansion. If you disagree, drop me a line and I'll answer your questions. Smile


* File         : user_restrictions_batch.module
* Title        : Batch add of user restrictions
* Sponsor      : Hangar Seven Digital
* Author       : Badzilla <a href="http://www.badzilla.co.uk" title="www.badzilla.co.uk">www.badzilla.co.uk</a> @badzillacouk
* This work is copyright Badzilla under the GPL licence terms and conditions

* Implements hook_menu().

function user_restrictions_batch_menu() { $edit_restrictions = array('edit user restriction rules');
$items = array(); $items['admin/config/people/user-restrictions/batch-input'] = array(
'title' => 'Batch input ',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_restrictions_batch_input_form', 4),
'access arguments' => $edit_restrictions,




user_restrictions_batch_input_form($form, &$form_state) { $form = array(); $form['banned'] = array(
'#type' => 'textarea',
'#title' => t('Enter prohibited words'),
'#required' => TRUE,
'#weight' => 0
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save rule'),




user_restrictions_batch_input_form_submit($form, &$form_state) { $lines = explode("\r\n", $form_state['values']['banned']);
    if (
$lines as $line) {
$phrases = explode(",", $line);

            if (

$phrases as $phrase)
                    if (
$phrase = trim($phrase))
fields(array('urid' => NULL, 'mask' => $phrase, 'type' => 'name', 'subtype' => '', 'status' => 0, 'expire' => 0))


name = User restrictions_batch
description = Brute force batch insertion of restricted words.
core = 7.x
project = "user_restrictions"

Attachment Size
user_restrictions_batch.tar.gz 1.06 KB

RSS Tags: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web