benbyf

deleting current user

Recommended Posts

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 zaib
      In PW I created a user 'tester' and gave the access to create edit and new. Issue is I'm unable to see 'edit' link in front of each page link and pages that i want to edit is already created.
      any help in this will be great help.
       
      Thank you.


    • By darrenc
      I'm trying to understand how I could have users log in as "members", provide them with a customized experience, but still serve them cached pages?
      For example let's say I have 3 roles
      Guest Member SuperUser And let's say I have a NavBar type component that has a menu. Plus it has "log in!" if guest,  or "logged in as Mike Smith"
      I would want guests to see a cached site with guest-only page access. Members should also see cached pages, but their menu may have access to members-only pages or fields or information. Furthermore they might have a "logged in as Mike Smith" element. SuperUsers can stay uncached. How does one go about creating that cache so that visitors aren't constantly re-creating the menu? Or that when "Sally Baker" logs in, she doesn't see a homepage that is cached for "Mike Smith" with all his elements?
      Thank you in advance for any replies. 
       
       
    • By prestoav
      I have a site built with a user role 'member' that can view some extra 'member area' pages. I have a user with the role 'editor' that has been given 'user-admin' permission who can successfully generate new users. However, when they try to add / change a 'member' role password to a 'member' role they get the error:
      Unable to generate password hash Does anyone know how to assign the 'editor' role the permission to generate a password for other user types?
      Thanks!
    • By zaib
      I've a simple scenario, i want to add two users "content_creator" & "content_publisher"
      content_creator can add new pages,edit them(only edit not publish) and view only where content_publisher can publish the unpublished pages after reviewing.
       
      Thank you.
    • By alan
      Sorry folks if this is obvious to most and I missed something in the docs or here in the forum, but, I have cheerfully used code such as:
      if($user->isLoggedin()) { echo " loggedIn"; } else { echo " notLoggedIn"; } in PW 2.x sites.
      Now on a v3 site I am finding even the most basic test to see if the viewer is logged in or `isSuperuser()` is not giving an error but simply doing nothing - not evaluating.
      For example, the top of a typical template reads:
      <?php namespace ProcessWire; if($user->isLoggedin()) { echo " loggedIn"; } else { echo " notLoggedIn"; } I have `debug` turned on.
      Is there something obvious I have missed, perhaps a step required for v3 that's not required for v2 to allow access to $user data?
      Thanks for any pointers.