1

I have created an artist registry that needs help deleting users that have not created a content type node "Artist Page".

I can find ways to delete users that are inactive, but in this case, some users might be inactive for years if nothing on their page has changed.

Preferably, I would first like to send a reminder email notice to users without an "Artist Page". When a user registers within the site they are instantly directed to fill out their artist page, but some users are only registering and not filling out their page, and of course, some registration spam is getting through.

Once an email is sent, and if no content is provided after a certain amount of time, I would like to delete them from the system to keep the site as clean as possible.

Any help would be greatly appreciated.

  • Is the artist page connected to the user's profile through a relationship, i.e. node reference or entity reference? Also - what version of Drupal are you using? – schnippy Dec 14 '13 at 0:58
0

if I understand you correctly then you have somekind of users and one content type "Artist Page". That users must fill (create) a node of that Artist Page content type. but some users may skip this step. In that case you can do following I think:

  1. node table has a uid field (author of content).
  2. Fetch separately (as array) uids of node and users tables and compare them;
  3. Get difference of arrays and compare there created time with current time, if difference is reaches(notification time) then send them an email, if difference is reaches(deletion time) then delete them.... These operation can be done on cron job. I recommend Elysia cron module.

Example:

function MY_MODULE_cronapi($op, $job = NULL) {
  $items['my_custom_task'] = array(
    'description' => 'My custom task description',
    'rule' => '*/20 * * * *', // Example rule - execute job every 20 min
    'callback' => 'my_custom_task',
    'arguments' => array(),
  );

  return $items;
}


function my_custom_task() {
  $subquery = db_select('node', 'n');
  ->fields('n', array('uid'))
    ->condition('n.type', 'MY_TYPE', '=')
    ->execute()
    ->fetchCol();

  $uids = db_select('users', 'u')
    ->fields('u', array('uid', 'created'))
    ->condition('u.uid', $subquery, 'NOT IN');
  ->execute()
    ->fetchAll();

  if(!$uids) {
    foreach($uids as $key => $uid) {
      $user_id = $uids[$key]->uid;
      $user_created = $uids[$key]->created;

      $notif_time_min = time() + 60*60*24*7; // example
      $notif_time_max = time() + 60*60*24*8; // example

      $del_time = time() + 60*60*24*15; // example

      if((time() - $user_created > $notif_time_min) && (time() - $user_created < $notif_time_max)) {
        // send_email()
      }
      elseif(time() - $user_created > $del_time) {
        //del_user()
      }
    }
  }
}

//P.S: I'd recommend to modify the callback part of cronjob. You can have too many users and every time cron job queries the tables(users and node tables) for existence of left users; Good solution will be creating a custom module which holds somekind of flag, which verifies that user is valid or not, you can flag as unverified on registration and change to verified on creation on node. This can be achieved by Rules or Action or custom code...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.