Jump to content
modifiedcontent

How to make a simple 'Delete My Account' link for users

Recommended Posts

I had a simple 'Delete My Account' link for users in my site that used to work fine, with a function like this:

Spoiler

if ( $input->post->forgetme ) {

	if ( $user->isSuperuser() ) {
	echo 'You should not be here...';
	$session->redirect('/');
	} 

	$items = $pages->find( 'name=' . $user->name );
		foreach($items as $item) {
		$item->delete();
		}
	$users->delete( $user );
	$session->logout();
	$session->redirect('/');
}

 

But it no longer works, after upgrades I guess. I get a fatal server error:

cannot be deleted: it is the current page being viewed, try $pages->trash() instead

Or when I use trash(), I get:

Exception: This page (id=XXXX) may not be placed in the trash

That error is thrown in core/PagesTrash.php by a check for isDeleteable(). I can't find info what makes a page 'deleteable' or not.

What is now the recommended way to do this?

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...