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 ragnarokkr
      Hi all!
      My first post here, and I'm pretty new to the PW thing, even if I'm falling in love with it  .
      Currently, I'm making a portal with PW and trying to add a few custom fields to the users' profile (image, socials, etc.).
      The issue here is that I'm able to add custom fields to the user profile, but PW doesn't save the values into these fields. It does let me insert the text or upload the image, but doesn't stores them into the database. And no error is printed out.
      By looking into the network traffic I did find that in some case it returns a JSON response:
      {"error":false,"message":"AJAX Page not saved (no changes)"} I've searched/googled about this particular issue but didn't find anything about it. I also have tried the solution described in this other topic (https://processwire.com/talk/topic/1002-cant-upload-imagefiles-problem/) to try in solving the image issue at least, without any good result.
      I thought the problem was maybe connected to the file permissions on the local installation, but the same situation has verified on remote test installation.
      I'm using latest stable PW version on WAMP:
      Apache v2.4.9 PHP v5.5.12 MySQL v5.6.17 Any idea, friends? Thanks.
    • By cybromancy
      Hi there, going a bit crazy here. Trying to be a user and change the role of another user.
      //get the user id to change $changeRole = $users->get($sanitizer->username('username'))->id; //add role $changeRole->addRole('moderator'); //save changes $users->save($changeRole);  
      What am I missing? Is it a user permissions setting? All I saw were permission settings for pages.
      Thanks up front for the help.
    • By Doc
      Hello,
      Newbie question here.
      I'm rebuilding my existing website with PW, it's a game where people can guess the winners of races.
      I used to have a "players" table. Those are registered players, I used to identify them through their login/password, and when it matches, I give them access to the website. No rocket science.
      So now with PW, I'm building my sign-up form and I'm trying to create a new session when a new user sign up.
      I'm retrieving user/pass from the sign-up form which has been posted before but :
      if($session->login($user, $pass)) {
          // login successful
          $session->redirect(elsewhere);
      }
      else
          echo "failed";
      ... fails everytime.
      Do I have to use something like :
      $u = new User(); $u->name = "bill"; $u->pass = "billpwd"; $u->addRole("guest"); $u->save(); ... before doing a session->login('bill', 'billpwd') ?? (I've just checked, it works, so I guess this is the good way to do it ?)
      I already have my players table so perhaps I can have the minimum in the PW's table and keep my players info in my historical table ?
      ... Or I can add all information I need into PW but I'd like to understand where it is stored.
      Last question, if there is a PW matching between "user" and "session", I need to give to the session->login function the password not hashed. I'm using the password_hash php function, any problem with that ?
      Thanks
       
       
    • By godmok
      Hi everyone,
      I have a problem with a member site where I put a link in CKEditor field thatshould go to a users profile page. The profile page is a site with one urlSegment, that contains the name of the user from the admin.
      The structure looks like this:
      -profiles --username (urlSegment) -some page (CKEditor field with a link to /profiles/username) -admin (PW admin area) --users ---username (user profile) So "some page" has a CKEditor field with a link to a profile page. Now the problem is, that this link source is always changed to the admin path and not the profiles (with urlSegment). A guest user can not look into this. Can this be deactivated, or is it wanted to work like this?
      My solution now is to create an additional page under "profiles" that is linked by a pagefield in the user profile. So a Link will always link to the "real" page under "profiles". Could there be a easier solution than creating an extra page as there is already one under admin but still let the links in CKEditor untouched?
      Thanks!
    • By benbyf
      quick question, can the $username in login() be email OR username, or anything else?