Jump to content

gebeer

Members
  • Content Count

    1,007
  • Joined

  • Last visited

  • Days Won

    23

Everything posted by gebeer

  1. For your password change functionality you could use something like this <?php $out = ''; // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'password-form'); // create password inputs from the built in PW password field $field = $modules->get("InputfieldPassword"); $field->label = "My new Password"; $field->attr("id+name","pass"); $form->append($field); // submit button! $submit = $modules->get("InputfieldSubmit"); $submit->label = " "; $submit->attr("value","Save Changes"); $submit->attr("id+name","submit"); $form->append($submit); // form was submitted so we process the form if($input->post->submit) { // user submitted the form, process it and check for errors $form->processInput($input->post); if ($form->id == "password-form") { //only process input from password form in case you have more forms in your dashboard //here you could do some validation logic but I don't think it is necessary if you only have password fields //to do validation and print out errors for the password field you would do something like $pass = $form->get("pass"); $_pass = $form->get("_pass"); if ($pass != $_pass) { $pass->error("passwords do not match"); } if($form->getErrors()) { // the form is processed and populated // but contains errors $out .= $form->render(); } else { //save new password $pass = $form->get("pass")->value; if ($pass != '') { $user->of(false); $user->pass = $pass; $user->save(); $user->of(true); } $out .= "Your changes have been saved."; $out .= $form->render(); } } } else { // render out form without processing $out .= $form->render(); } echo $out; ?> Note: don't sanitize passwords as that might change them and then user can't login.
  2. OK, my hookDeleteUsers function now reads public function hookDeleteUsers($event){ exit("hallo"); $userpage = $event->arguments("page"); if($userpage->id){ $userPages = wire("pages")->find("created_users_id={$userpage->id}"); foreach ($userPages as $userPage) { wire("pages")->trash($userPage); } $this->message("All pages of user {$userpage->name} deleted"); } } But I don't get a "hallo" on delete and all user's pages are still there. So I guess the hook doesn't get called.
  3. Based on Somas input, my CleanupUserPages.module now contains: <?php class CleanupUserPages extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Cleanup User Data', 'version' => 0.1, 'summary' => 'Trashes all pages that where created by a user after user has been deleted', 'singular' => true, 'permanent' => false, 'permission' => 'user-admin', 'autoload' => true, ); } public function init() { $this->users->addHookBefore("delete", $this, "hookDeleteUsers"); } public function hookDeleteUsers($event){ $userpage = $event->arguments("page"); if($userpage->id){ $userPages = $pages->get("created_users_id={$userpage->id}"); $this->pages->trash($userPages); $this->message("pages deleted"); } } } ?> I have installed the module. But when I delete a user, nothing happens. To test if the module gets called, I added var_dump($userpages); return; right after $userpage = $event->arguments("page"); But still nothing happens. It seems like the module code is not being executed at all. Does $this->users->addHookBefore make sense or do I need to define the hook in some other way?
  4. Thank you kongondo, this is working great!
  5. Hi, I'm trying to setup a page field with a custom selector. Intention is to show only pages of the currently logged in user in the select drop down. Here's what I tried in the field setup: I also tried But I guess this doesn't make a lot of sense because when the page is created and has not been saved yet, the $page->createdUser isn't there yet. I always get an empty select It seems like the page field is not aware of the $user object. Is there any way how I could filter the pages by created_users_id, maybe through a hook on that field?
  6. Thanks again Soma, for your help. Your explanations again are really clear to understand. Based on what I know now, I will try and put the module together. @admins: I should have posted this in the modules forum. You're welcome to move it over there.
  7. Thanks Martijn. I just followed a link to Captain Hook on https://processwire.com/api/hooks/. When I browse http://processwire.com/api/hooks/captain-hook/ the site is working. Whom can I notify and inform about this issue? Github issues?
  8. Hello, I'm trying to learn more about hooks and visited Captain Hook. That page is currently not loading any styles and scripts. My console says: Blocked loading mixed active content "http://somatonic.github.com/Captain-Hook/css/anchor.css" Loading mixed (insecure) display content on a secure page "http://somatonic.github.com/Captain-Hook/hook.png" Blocked loading mixed active content "http://somatonic.github.com/Captain-Hook/js/jquery.js" Blocked loading mixed active content "http://somatonic.github.com/Captain-Hook/js/quicksilver.js" Blocked loading mixed active content "http://somatonic.github.com/Captain-Hook/js/main.js" Blocked loading mixed active content "http://somatonic.github.com/Captain-Hook/js/jquery.js" Blocked loading mixed active content "http://somatonic.github.com/Captain-Hook/js/quicksilver.js" Blocked loading mixed active content "http://somatonic.github.com/Captain-Hook/js/main.js"
  9. Now I'm aware of lightning.pw, too. Awesome!
  10. I t does have a title field in the template. Just renamed The Label there to "Login Name".
  11. OK, bummer. Blame on me not checking the source and stealing your time. Can I buy you a beer/soda/coffee? I'm using same menu code in a different project where no problems with menu rendering appeared so far. Actually I took the code from here. Found it: I had commented out a part in the rendering function that prevented displaying pages with children. Slapping myself hard now. Credits for solving this go to Soma.
  12. The profile page itself shows fine. But there should also be a menu item "Profiles" visible in the top menu bar next to "Home". when logged in as frontend user. That is my problem. I thought, too, that it wouldn't matter to have 2 different templates or only one. That was just the only difference that I noticed when comparing your settings to mine.
  13. my custom login definitely logs user in. You can see it on my def site which I pmed you details to.
  14. Thanks a ton! Only difference to my setup is that your login is through the default pw login page while mine is through the frontend.
  15. These are the access settings now for my Profiles page with template userprofiles The Profiles page still doesn't show in the menu, although it says in the settings: No - Pages may NOT not appear in searches/lists unless the user has access to view them My logged in user has role guest and frontend. Role frontend has these permissions: Sorry, I still can't see why the menu item would not be visible.
  16. I'll try harder first and get back here if I don't succeed. Thank you again for your help.
  17. That approach totally makes sense to me and fits my project requirements very well, especially since I also want to keep frontend users out from the admin area. My Profile page has guest view permissions removed. Only frontend user role is allowed to view it. But still it does NOT show up when frontend user is logged in. And I don't know why. You can see my role and template setup in my first post. So I guess something must still be wrong with my role/template access setup. Still lost on this one.
  18. Thank you Soma, for taking your time and explaining things that precisely. This really helped me to get a better understanding of the whole role and permissions concept. I will alter my frontend role like you suggested and add checks for $user->isLoggedin() && $user->hasRole("frontend") in my templates. If I get you correctly on the navigation render: It is expected behaviour that the Profile page does NOT show, right? So I need to render an extra users menu with links to their profile page and whatever else they need? Pls confirm. Thank you.
  19. Hi all, I'm struggling in putting together a process module. I want to trash all pages that belong to a specific user after the user has been deleted. I found one related thread by onjegolders where he is doing things the other way around. In my case I need a process module that hooks after user delete. And I would like to use the wire/modules/Process/ProcessPageTrash.module. It is my first time creating a pw process module. I have read through the basics of creating modules including the wiki article and looked at the code of ProcessPageTrash.module. But I'm having a hard time putting things together. This is what I've got so far: class ProcessCleanupUserPages extends Process { public static function getModuleInfo() { return array( 'title' => 'Cleanup User Data', 'version' => 0.1, 'summary' => 'Deletes all pages that where created by a user after user has been deleted', 'singular' => true, 'permanent' => false, 'permission' => 'user-admin', 'requires' => 'ProcessPageTrash', 'autoload' => "process=ProcessPageList", // What to add here - autoload only on user list page ); } public function init() { $this->users->addHookAfter('delete', $this, '___execute()'); // is this correct? } public function ___execute() { //get user ID $userID = $this->id or $event->id // How to get the user ID? //get all pages that were created by the deleted user $userPages = $pages->get("created_users_id={$userID}"); // syntax for trash pages - call module ProcessPageTrash on $userPages } protected function render() { // print out message to admin after pages are successfully trashed } } ?> I added comments with "???" where I don't know exactly what to do. Any help would be much appreciated. Thank you.
  20. The problem happened to be related to old session files that I transferred when moving to the new server. Once I deleted all session files in assets/sessions on the new server, PW picks up the $config->httpHosts array and the error message in the backend disappears.
  21. The problem happened to be related to old session files that I transferred when moving to the new server. Once I deleted all session files in assets/sessions on the new server, PW picks up the $config->httpHosts array. The error message in the backend disappears and I can create users and save their passwords without problems.
  22. @netcarver I added the link to that post. @onjegolders The profiles page is neither unpuplished nor hidden. It's template "userprofile" has access rules defined as per screenshot I supplied in my original post. I'm using this function to loop out my navigation: function renderChildrenOf($pa, $output = '', $level = 0) { $output = ''; $level++; foreach ($pa as $child) { $atoggle = ''; $class = ''; if ($child->numChildren(true) && count($child->parents) == 1) { $class .= 'dropdown'; $atoggle .= ' class="dropdown-toggle" data-toggle="dropdown"'; } else if ($child->numChildren(true) && count($child->parents) > 1 ) { $class .= 'dropdown-submenu'; $atoggle .= ' class="dropdown-toggle"'; } else if ($child->numChildren(true) && $child->id != 1) { $class .= 'dropdown-menu'; } // Makes the current page and it's top level parent add an active class $class .= ($child === wire("page") || $child === wire("page")->rootParent) ? " active" : ''; $class = strlen($class) ? " class='" . trim($class) . "'" : ''; if ($child->numChildren(true) && count($child->parents) == 1) { Add Caret if have children $output .= "<li$class><a href='$child->url'$atoggle>$child->title <b class='caret'></b></a>"; } else if ($child->numChildren(true) && count($child->parents) > 1) { $output .= "<li$class><a tabindex='-1' href='$child->url'$atoggle>$child->title</a>"; } else { $output .= "<li$class><a href='$child->url'$atoggle>$child->title</a>"; } // If this child is itself a parent and not the root page, then render it's children in their own menu too... if ($child->numChildren(true) && $child->id != 1) { $output .= renderChildrenOf($child->children, $output, $level); } $output .= "</li>"; } $outerclass = ($level == 1) ? "nav navbar-nav navbar-right" : 'dropdown-menu'; return "<ul class='$outerclass'>$output</ul>"; }
  23. I'm on the road. Will.supply the link tomorrow.
  24. After moving the site to the new host I have specified the new domain in the config file. But it is not recognized by PW. What ever I assign to $config->http hosts array, I always get that error.
  25. If you are talking about include paths in my templates, they are all correct.
×
×
  • Create New...