Deletes a user.

@param string $search Email or username
@throws \Exception
@throws \Throwable
@throws \yii\db\StaleObjectException
763171
public function actionDelete($search)
    {
        if ($this->confirm(Yii::t('yuncms', 'Are you sure? Deleted user can not be restored'))) {
            $user = User::findByEmailOrMobile($search);
            if ($user === null) {
                $this->stdout(Yii::t('yuncms', 'User is not found') . "\n", Console::FG_RED);
            } else {
                if ($user->delete()) {
                    $this->stdout(Yii::t('yuncms', 'User has been deleted') . "\n", Console::FG_GREEN);
                } else {
                    $this->stdout(Yii::t('yuncms', 'Error occurred while deleting user') . "\n", Console::FG_RED);
                }
            }
        }
    }
873950
def delete():
    ''''''
    email = click.prompt('Email')
    user = User.objects(email=email).first()
    if not user:
        exit_with_error('Invalid user')
    user.delete()
    success('User deleted successfully')
800030
def delete(ctx, query, force):
    

    ensure_validated(ctx)
    controller = ctx.obj['controller']
    creds = controller.list()
    hits = _search(creds, query)
    if len(hits) == 0:
        click.echo('No matches, nothing to be done.')
    elif len(hits) == 1:
        cred = hits[0]
        if force or (click.confirm(
                u'Delete credential: {} ?'.format(cred.printable_key),
                default=False, err=True
        )):
            controller.delete(cred)
            click.echo(u'Deleted {}.'.format(cred.printable_key))
        else:
            click.echo('Deletion aborted by user.')

    else:
        _error_multiple_hits(ctx, hits)
1259733
public function deleteUser($username)
    {
        $stmt = $this
            ->conn
            ->prepare(sprintf("DELETE * FROM %s WHERE user_name = :name", $this->table))
            ->execute(['name' => $username]);
        return $stmt->rowCount();
    }
617334
def _delete_from_search_index(*, instance, index):
    """"""
    pre_delete.send(sender=instance.__class__, instance=instance, index=index)
    if settings.auto_sync(instance):
        instance.delete_search_document(index=index)
491547
public function find_users($search) {
        global $DB;
        // By default wherecondition retrieves all users except the deleted, not confirmed and guest.
        list($wherecondition, $params) = $this->search_sql($search, 'u');
        $params['enrolid'] = $this->enrolid;

        $fields      = 'SELECT ' . $this->required_fields_sql('u');
        $countfields = 'SELECT COUNT(1)';

        $sql = " FROM {user} u
                 JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid = :enrolid)
                WHERE $wherecondition";

        list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
        $order = ' ORDER BY ' . $sort;

        if (!$this->is_validating()) {
            $potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
            if ($potentialmemberscount > $this->maxusersperpage) {
                return $this->too_many_results($search, $potentialmemberscount);
            }
        }

        $availableusers = $DB->get_records_sql($fields . $sql . $order, array_merge($params, $sortparams));

        if (empty($availableusers)) {
            return array();
        }


        if ($search) {
            $groupname = get_string('enrolledusersmatching', 'enrol', $search);
        } else {
            $groupname = get_string('enrolledusers', 'enrol');
        }

        return array($groupname => $availableusers);
    }
774093
@Override
    public void deleteUser(String username) throws AuthenticationException {
        String user = file_store.getProperty(username);
        if (user == null) {
            throw new AuthenticationException("User '" + username
                    + "' not found.");
        }
        file_store.remove(username);
        try {
            saveUsers();
        } catch (IOException e) {
            throw new AuthenticationException("Error deleting user: ", e);
        }
    }
938924
public static function removeByUsername(string $username) {
		$userdbname = setup::getValidation("username");
		if ($user = R::findOne('user', ' ' . $userdbname . ' = ? ', [$username])) {
			R::trash($user);
		}
	}
156825
public static function delete($request, $match)
    {
        $group = Pluf_Shortcuts_GetObjectOr404('User_Group', $match['group_id']);
        $user = Pluf_Shortcuts_GetObjectOr404('User_Account', $match['user_id']);
        $group->delAssoc($user);
        return $user;
    }
499035
public function findByNameForAjax($search)
    {
        $resultArray = [];

        $users = $this->findByName($search);

        foreach ($users as $user) {
            $resultArray[] = [
                'id' => $user->getId(),
                'text' => $user->getFirstName().' '.$user->getLastName(),
            ];
        }

        return $resultArray;
    }
10247
public function delete( $id = null, $attributes = array(), $search = false )
    {
        $this->forceStoreRegistry = true;
        parent::delete( $id, $attributes, $search );
    }
739110
public function deleteUser(User $user)
    {
        if ($user->isGuest()) {
            Throw new UserException('Cannot delete a guest user.');
        }

        // Check the old password
        $this->db->delete($this->table, 'id_user=:id_user', [
            ':id_user' => $user->getId()
        ]);
    }
536087
public function setSearch(SearchInterface $search)
    {
        if (null !== $this->search) {
            $this->search->free();
        }
        $this->search = $search;
        $this->rewind();
    }
511763
public function searchUsers($search)
    {
        $users = $this->userRepository->findByName($search);

        return new JsonResponse(array_map(function (User $user) {
            return $this->userSerializer->serialize($user);
        }, $users));
    }
810506
public function deleteUser($user) {
        global $DB;

        $DB->delete_records($this->userresulttable, ['id' => $user->getRecordId()]);
        $user->initialize();

        return true;
    }
1371442
public function deleteUser($userLogin)
    {
        Piwik::checkUserHasSuperUserAccess();
        $this->checkUserIsNotAnonymous($userLogin);

        $this->checkUserExist($userLogin);

        if ($this->isUserTheOnlyUserHavingSuperUserAccess($userLogin)) {
            $message = Piwik::translate("UsersManager_ExceptionDeleteOnlyUserWithSuperUserAccess", $userLogin)
                        . " "
                        . Piwik::translate("UsersManager_ExceptionYouMustGrantSuperUserAccessFirst");
            throw new Exception($message);
        }

        $this->model->deleteUserOnly($userLogin);
        $this->model->deleteUserAccess($userLogin);

        Cache::deleteTrackerCache();
    }
409336
public static function delete( $key ) {

		if ( isset( self::$config[ strtolower( $key ) ] ) ) {
			unset( self::$config[ strtolower( $key ) ] );
		}

	}