working self cancelation in drual 7

Working self cancelation in drual 7 Php code

<?php
global $user;
if(in_array(4,array_keys($user->roles)) && !in_array(3,array_keys($user->roles))){
$result = db_query(‘SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = :uid AND n.type = :type’, array(‘:uid’ => $user->uid,’:type’ => ‘product’));
foreach ($result as $record) {
node_delete($record->nid);
}
$email = $user->mail;
$message = “Your account has been deleted from : http://www.ilmurodipasquino.com/drupal/ “;
mail($email, ‘Account Deleted’, $message);
user_delete($user->uid);
drupal_goto(‘newteacher/register/’);
}
else{
echo ‘<div style=”color:#f00;”>Only teachers can disable their own accounts</div>’;
}
?>

Was this article helpful?

Related Articles