Removing Old Users

Re: Removing Old Users

by Mahinwal Surya -
Number of replies: 0

Hi, 

I think this will help you.

include these files on top of your page.

require_once('../../config.php');

require_once($CFG->dirroot."/lib/moodlelib.php");

global $CFG, $DB, $USER;

and

call this function: delete_user(stdClass $user);

NOTE:

  •  Marks user deleted in internal user database and notifies the auth plugin.
  •   Also unenrols user from all roles and does other cleanup.
  •   Any plugin that needs to purge user data should register the 'user_deleted' event.
  •  @param stdClass $user full user object before delete
  •  @return boolean success
  •  @throws coding_exception if invalid $user parameter detected.


Thanks