User login

Select multiple users to delete sorted by registration date and with one profile field (Drupal 4.7)

Side note: Deleting directly with MySQL:
DELETE p, u FROM dru_profile_values p LEFT JOIN dru_users u ON p.uid = u.uid WHERE u.created > 1317450417

On to the long obsolete main show:

If you are unfortunate enough to be doing anything on Drupal 4.7, here is a bit of empathy.

If you have a 4.7 site, it probably has a lot of spam registrations. Drupal 4.7 doesn't have a multiple user delete. And Userplus module doesn't provide a very useful list in its multiple user delete.

Here's minor modifications to two userplus.module functions that made its delete a whole lot more functional for my theoretical Drupal 4.7 site.

<?php
function userplus_delete_users() {
 
$weight = 0;
 
$form['user'] = array('#tree' => true);
 
$form['usermap'] = array('#tree' => true);
 
 
$result = pager_query('SELECT u.uid, u.name, u.created, p.value FROM {users} u LEFT JOIN {profile_values} p ON u.uid = p.uid WHERE u.uid > 0 AND p.fid = 1 ORDER BY u.created DESC', variable_get('userplus_max_delete_users', 25));
  while (
$user = db_fetch_object($result)) {
   
$form['user'][$user->uid] = array('#type' => 'checkbox', '#attributes' => array('title' => $user->name), '#default_value' => false, '#weight' => $weight++);
   
$form['phone'][$user->uid] = array('#type' => 'markup', '#value' => $user->value);
   
$form['usermap'][$user->uid] = array('#type' => 'hidden', '#value' => $user->name, '#weight' => $weight++);
  }
 
 
$form['submit'] = array('#type' => 'submit', '#value' => t('Delete checked users'));
 
  return
drupal_get_form('userplus_delete_users', $form);
}

function

theme_userplus_delete_users($edit) {
 
$rows = array();
 
 
$header = array(t('User'), t('Phone'), t('Delete'), '');

  foreach (

element_children($edit['user']) as $uid) {
    unset(
$row);
   
$row[] = array('data' => l($edit['user'][$uid]['#attributes']['title'], "user/$uid/edit"), 'class' => 'username');
   
$row[] = form_render($edit['phone'][$uid]);
   
$row[] = form_render($edit['user'][$uid]);
   
$row[] = form_render($edit['usermap'][$uid]);   
   
$rows[] = $row;
  }
 
 
$output = theme('table', $header, $rows, array('id' => 'delete-users'));
 
$output .= '<br \>';
 
$output .= form_render($edit['submit']);
 
$output .= theme('pager', NULL, variable_get('userplus_max_delete_users', 25));
 
 
// Don't forget the dreaded form_id -- <a href="http://drupal.org/node/38926" title="http://drupal.org/node/38926">http://drupal.org/node/38926</a> -- or
  // the values won't be there when you get to your _submit handler...
 
$output .= form_render($edit['form_id']);

 

// Form_token is necessary to pass validation -- see
  // <a href="http://drupal.org/node/89999" title="http://drupal.org/node/89999">http://drupal.org/node/89999</a> for more information.
 
$output .= form_render($edit['form_token']);

  return

$output;
}
?>