benbyf

deleting current user

2 posts in this topic

within my module not sure how to delete the current user and redirect without incurring this error:

Fatal error: Exception: You do not have permission to execute this module - ProcessPageView (in /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Modules.php line 1022) #0 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Modules.php(940): Modules->getModule('ProcessPageView') #1 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Session.php(609): Modules->get('ProcessPageView') #2 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Wire.php(398): Session->___redirect('/') #3 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/Wire.php(333): Wire->runHooks('redirect', Array) #4 /srv/users/serverpilot/apps/betaville-dev/public/site/modules/Subscribers/Subscribers.module(345): Wire->__call('redirect', Array) #5 /srv/users/serverpilot/apps/betaville-dev/public/site/templates/login.php(27): Subscribers->deleteUser('benjaminbyford5...') #6 /srv/users/serverpilot/apps/betaville-dev/public/wire/core/TemplateFile.php(182): require('/srv/users/serv...') #7 /srv/users/serverpilot/apps/betavi in /srv/users/serverpilot/apps/betaville-dev/public/index.php on line 248

 

$u = $this->user;

// user found and deleted
$this->users->delete($u);

// send to homepage
$homepage = $this->pages->get('/');
$this->session->redirect($homepage->url);

 

Share this post


Link to post
Share on other sites

Not sure, but maybe try hooking after: Session::redirect

Or maybe you need to: $session->logout() first.

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.

  • Similar Content

    • By foxcraft_aw
      Hello!
      I have a strange problem with the "delete" method of the "pages" API-variable: When I insert a parent- and a child-page, and then immediately try to delete first the child- and then the parent-page, an exception is thrown telling me that the parent cannot be deleted, because it still contains a child-page.
      You can reproduce this behaviour using the following code:
      <?php require 'index.php'; $parentPage = new ProcessWire\Page; $parentPage->name = 'parent'; $parentPage->template = 'basic-page'; $parentPage->title = 'parent'; $parentPage->parent = $pages->get('/'); $parentPage->save(); $childPage = new ProcessWire\Page; $childPage->name = 'child'; $childPage->template = 'basic-page'; $childPage->title = 'child'; $childPage->parent = $pages->get('/parent'); $childPage->save(); $pages->delete($pages->get('/parent/child')); $pages->delete($pages->get('/parent')); (I put this code into a file called "experiments.php" in the root directory of the site, because I do not know of any better way for quickly testing out code in ProcessWire yet)
       
      Can you tell me why this code throws an exception?
      What am I missing?
      I am using ProcessWire 3.
      Thanks for your help!
       
      PS: Yes, I know about the second parameter in the "$pages->delete" method, but it should not be necessary to be set in this scenario if I`m correct.
    • By fbg13
      When echoing a date field directly from the $user variable
      echo $user->date;  the timestamp is printed. Using
      echo $users->get($user->id)->date; prints the correct formated value.
      Is this a bug or or intended?
    • By modifiedcontent
      I am trying to rewrite Soma's suggestion here to export fields from the users database to a cvs file, with variations like this:
      $array = $users->explode(function($item){ ...etc. And
      $array = $users->find('start=0')->explode(function($item){ ... But keep getting 'Call to a member function ... on a non-object' errors. I guess $users is the non-object?
      I am trying to use this within a function, that is called with a button click. Is $users not available within a function?
      I see there are new export/import features coming up - great! - but it is all about $pages. Should $users work the exact same way?
      This works as demo starting point. Now I just have to replace the $list with something from $users:
       
    • By beto
      I can't add a new value to a custom PageArray field  for my user.
       
      However, when I create a new user, I CAN add the new PageArray value:
       
      I need help. Thank you very much.
       
    • By gebeer
      Hello,
      I have a Process module with a user dashboard and I would like to have the user page edit screen at a custom URL 'myprofile'.
      I cannot use the default profile edit page because it does not support tabbed interfaces.
      The method for executing the user edit page from within my module looks like this
      public function ___executeMyprofile() { $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } The user edit screen displays when I go to /dashboard/myprofile. But the request is redirected several times and I end up at the URL /access/users/edit/?id=5522 which I wanted to avoid.
      This happens because of this line in ProcessPageEdit.module.
      I guess the solution lies in hooking into the ___loadPage() method from within my Process module. But, honestly, I have no clue on how to put the pieces together.
      So I need some pointers on how to best achieve the goal of having the current user's edit page under a custom URL in the admin area, ideally in the scenario of a custom Process module.
      Any help would be much appreciated.
      EDIT:
      I tried some variations of hooking like
      public function ___executeMyprofile() { $this->addHookBefore("ProcessPageEdit::loadPage", $this, "interceptRedirect"); $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } protected function interceptRedirect(HookEvent $event) { $event->replace = true; $event->return = $this->user; } but the hook is not being executed at all. Also when placing the call to the hook in my Process module's init() method. Also when using an After hook and not replacing the hooked method. No luck so far...